I have a restaurant/takeaway website in the pipeline. I have tried using both taxonomy and product pricing attributes to create the ability to add extras such as extra cheese or extra pizza toppings.

Both of these methods involves a rule which updates the price.

The issue is that the price is not taking effect in the cart block. It is not adding to the base price of the product when an extra/option has been selected for that product.

Comments

joe huggans’s picture

Issue summary: View changes
joe huggans’s picture

We are willing to pay to get this sorted ASAP. Anyone?

saurabh.dhariwal’s picture

Hello,

Follow the steps provided below.

Create new taxonomy named "Pizza Toppings", and add new field Price in it.
Add terms in "Pizza Toppings" like Cheese, Garlic etc with associative price.

Add new field in line item (Product) with term reference(Pizza Toppings).

Tick "Include this field on Add to Cart forms for line items of this type" checkbox under "ADD TO CART FORM SETTINGS".

This will display your "Pizza toppings" terms on add to cart form.

Now create new "Product Pricing rule" from Store > Configuration > Product Pricing Rule.

1) Select event "Calculating the sell price of a product".
2) Add Condition "Entity has field" with Data selector "commerce-line-item" and field "field_pizza_toppings"
3) In Action section, add Loop for pizza toppings of commerce line item.
> Add action under Loop to "Add an amount to the unit price" with data selector as commerce_line_item and for AMOUNT take pizza toppings amount.
> Select fee from drop down as "PRICE COMPONENT TYPE".

This will add your selected toppings price into your line item total.

Let me know incase of any query/concern regarding this.

Thanks!

joe huggans’s picture

Thanks Alot! Will try this out soon

dgregory’s picture

I see that this is an old post, but hope to receive a hand.

I've run into a similar issue and am attempting to do these steps. I've completed all steps as stated in your directions saurabh.dhariwal but I am stuck at the step for adding the action (beneath the created loop). I chose the data selector: "commerce_line_item", but then for the AMOUNT section, cannot find a data selector for my field for amount. So in your example, I believe you are saying that the data selector that should be selected would be "commerce-line-item:field-pizza-toppings:amount", but I cannot find this for my field. I attempted to just add the commerce line item data selector for mine, but it does not accept this.

Have I missed an important step in which an "...:amount" data selector would have been created?

Thanks for your support!

subhojit777’s picture

Same as @saurabh.dhariwal's steps, but improved and more verbose:

  • Create new taxonomy named "Pizza Toppings", and add new field Price in it.
  • Add terms in "Pizza Toppings" like Cheese, Garlic etc with associative price.
  • Add new field in line item (Product) with term reference (Pizza Toppings).
  • Tick "Include this field on Add to Cart forms for line items of this type" checkbox under "ADD TO CART FORM SETTINGS". This will display your "Pizza toppings" terms on add to cart form.
  • Make sure the field is multivalued
  • Now create new "Product Pricing rule" from Store > Configuration > Product Pricing Rule.
    • Select event "Calculating the sell price of a product".
    • Add Condition "Entity has field" with Data selector "commerce-line-item" and field "field_pizza_toppings"
    • In Action section, add Loop for commerce-line-item:field-pizza-toppings data selector. Say, the variable name is pizza_topping
    • Add action under Loop to "Add an amount to the unit price" with data selector as commerce_line_item and for AMOUNT pizza-topping:field-price:amount
    • Select fee from drop down as "PRICE COMPONENT TYPE".
subhojit777’s picture