0

I want have a product that user can change the price of it to custom ,I want programmically change the price of product when user submit a custom form with entered price.

my require is I want to have product that according to entered value by user ,product price change and then add to his/her cart. really I dont know how can I achieve it. appreciate any urgency help

3

I suppose the existing answer is fine if every customer gets a unique version of the product to purchase. However, it should be obvious that if more than one person uses this it would fail.

You should instead look at what we recommend in this video tutorial:

http://www.drupalcommerce.org/videos/tutorials/donations-custom-line-item-types

The main idea is that you can enrich the line item with custom pricing information and then use the product sell price calculation system to swap in the appropriate custom price.

0

I found simple method, load product and then update product:

  $product = commerce_product_load((int)$product_id);
  $product->commerce_price_usd["und"][0]["amount"]=$price;
  commerce_product_save($product); 

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.