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?
-
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 ?– taggartJMay 30, 2018 at 0:47
-
wait i used to work for you guys ... give me a call lol.– taggartJMay 30, 2018 at 0:54
3 Answers
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.
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.
-
Thanks .. I also needed to hide the price. Checking that option still displays the price.– neubreedMay 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.– YaazkalMay 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– neubreedJun 7, 2018 at 0:56
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 %}