I want to alter a product price (for example saved at 0.70€ in store). I pulled the hair several hours to find how to change the unit price (and the impact on the total price by changing the quantity) when putting the cart and / or from the time we are on the cart .

In fact, I need a base price, and according to certain client I modified by an external data (webservice). This modified price should not be saved but just used to that moment until the checkout process is complete.

In everything I tried, including the hook_commerce_cart_line_item_refresh() the price is never changed.

An idea to save me?

1 Answer 1


Have you read any of the product pricing rules documentation or watched the tutorials on DrupalCommerce.org? It's all in there: http://www.drupalcommerce.org/user-guide/product-pricing-rules-screencasts

In other words, you shouldn't be hooking into anything, you should be using Drupal Commerce's core product pricing rules system. This is the only supported way to make consistent line item unit price alterations that are reflected in the final order total.

Your Answer

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

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