Magento, How to change product price in view page?

Expert wanna be

In Magento product view page,

I need to call 3rd party API with product option to get product price, and I need to change the product price dynamically.

How can I update the product price in view page so that I can pass right price to cart?

I tried adding this input tag in options.phtml,

<input type='text' name='price' value='999' />

and I click 'Add to cart' button, but the price is not changed in cart page.

please advise me,

Ankur Goyal

You will not be able to set custom price in this way because when magento add a products to cart it does not take price from the form post data.

In magento,there is option of setting custom price of product at run time.So you have to call a observer on checkout_cart_product_add_after event and in that observe,get the custom price from the form post data and set the product custom price in following way:

  $request=$observer->getRequestParam();
  $price=$request->getPrice();
  $qty=1;
  $item = $observer->getQuoteItem();
  $item->setCustomPrice($price*$qty);
  $item->setOriginalCustomPrice($price);
  // Enable super mode on the product.
  $item->getProduct()->setIsSuperMode(true);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to view product price in right bar in magento product details page

From Dev

Magento: Change product price by getting product id

From Dev

magento custom price change like configurable product

From Dev

Magento: Change Product Position in Categories based on price

From Dev

Magento simple product price not updating after change

From Dev

How can I change the original price on OpenCart product page?

From Dev

Magento Configurable Product DropDown - Must Change "Price Difference - +" To Actual Price

From Dev

Magento - display product reviews on product view page

From Dev

how to display custom attribute on product view page in magento 1.9?

From Dev

How to change the Magento home page product breadcrumbs path

From Dev

Magento Tier Price on Category view is different from Product view

From Dev

Show Sale product on category view page Magento

From Dev

Change Magento bundle product price type via database

From Dev

Change Product Price as per Radio Button Selection - Magento

From Dev

how to change custom option price by query in magento?

From Dev

how to change custom option price by query in magento?

From Dev

How to Change the price before adding to cart in magento?

From Dev

How to remove Price from Product Category page?

From Dev

magento add column after product tab in product view page

From Dev

How can i show custum price for a specific product type in magento

From Dev

Magento bundle product price not visible

From Dev

How to call a product list in a produt view Magento

From Dev

Magento - How to add extra button like "Add to cart" and Redirect to external url from grid view, list view and product page view.

From Dev

How to Protect user,for visit product page in magento

From Dev

How to show product description at home page in magento

From Dev

How to Protect user,for visit product page in magento

From Dev

How to change in the Magento DB the prices of the product

From Dev

insert magento single product with list view on custom page

From Dev

W3C validator issue in magento product view page

Related Related

  1. 1

    how to view product price in right bar in magento product details page

  2. 2

    Magento: Change product price by getting product id

  3. 3

    magento custom price change like configurable product

  4. 4

    Magento: Change Product Position in Categories based on price

  5. 5

    Magento simple product price not updating after change

  6. 6

    How can I change the original price on OpenCart product page?

  7. 7

    Magento Configurable Product DropDown - Must Change "Price Difference - +" To Actual Price

  8. 8

    Magento - display product reviews on product view page

  9. 9

    how to display custom attribute on product view page in magento 1.9?

  10. 10

    How to change the Magento home page product breadcrumbs path

  11. 11

    Magento Tier Price on Category view is different from Product view

  12. 12

    Show Sale product on category view page Magento

  13. 13

    Change Magento bundle product price type via database

  14. 14

    Change Product Price as per Radio Button Selection - Magento

  15. 15

    how to change custom option price by query in magento?

  16. 16

    how to change custom option price by query in magento?

  17. 17

    How to Change the price before adding to cart in magento?

  18. 18

    How to remove Price from Product Category page?

  19. 19

    magento add column after product tab in product view page

  20. 20

    How can i show custum price for a specific product type in magento

  21. 21

    Magento bundle product price not visible

  22. 22

    How to call a product list in a produt view Magento

  23. 23

    Magento - How to add extra button like "Add to cart" and Redirect to external url from grid view, list view and product page view.

  24. 24

    How to Protect user,for visit product page in magento

  25. 25

    How to show product description at home page in magento

  26. 26

    How to Protect user,for visit product page in magento

  27. 27

    How to change in the Magento DB the prices of the product

  28. 28

    insert magento single product with list view on custom page

  29. 29

    W3C validator issue in magento product view page

HotTag

Archive