0

What's the best way to configure some products so that they are not on sale .. i.e not show the price or add to cart button without creating a new product type?

2
  • ok there are a few ways to go about this ... but not defaut functionality as products assume you want to sell stuff ... have you thought of creating a config entity where you could mark products that are not for sale ?
    – taggartJ
    May 30, 2018 at 0:47
  • wait i used to work for you guys ... give me a call lol.
    – taggartJ
    May 30, 2018 at 0:54

3 Answers 3

0

Ideas...

1) create custom config entity like "products_not_on_sale"

2) Alter node view to hide the fields if referenced in above ^

--- or ---

1) add new field of type bool to say item on sale or not.

2) alter node view to hide fields if value is checked.

0

You just need to uncheck the active option on each product variation. That will hide the "Add to cart" button and price without hidding the product or its information.

enter image description here

3
  • Thanks .. I also needed to hide the price. Checking that option still displays the price.
    – neubreed
    May 31, 2018 at 1:48
  • I've tried this on a live site an also on simplytest.me with a clean commerce site. It hides price and "add to cart" button. At least in the product page.
    – Yaazkal
    May 31, 2018 at 12:51
  • I'm using Panelizer and I don't think it works with that module. I turned Panelizer off for the product page and the Active switch appears to wiork
    – neubreed
    Jun 7, 2018 at 0:56
0

Thanks. I ended up achieving what I wanted in a twig template by copying it from the below path:

modules/contrib/commerce/modules/product/templates/commerce-product-variation.html.twig

to:

themes/custom/mytheme/templates/product/commerce-product-variation--summary.html.twig

"summary" is the display for the panels page I've configured.

Then used the variation active status boolean value to determine whether or not to show it:

{% if product_variation_entity.status.value != 0 %}
<div{{ attributes }}>
  {{- product_variation -}}
</div>
{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.