I'm trying to ask the same question in another way... hoping I can get an answer.

I have a function I need to trigger AFTER the product is added to the cart.

When I added a PHP function to a Pricing Rule it seems to execute -before- the product is added.

The Commerce website says that the a Pricing Rule may be triggered before or after the line item is added but I can't figure out how to do this.

1 Answer 1


You've got a rules event that fires when a product is added to the cart, which is called after the price calculation one, check commerce_cart_product_add function.

It uses rules_invoke_all, which means that you can either run actions on this event or invoke the hook directly, hook_commerce_cart_product_add normally.

// Invoke the product add event with the newly saved or updated line item.
rules_invoke_all('commerce_cart_product_add', $order, $product, $quantity, $line_item);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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