[Skip to main content](#vessel-content)

#   Product price editable on checkout

##

- **[toninom](/forum/user/37813-toninom "View toninom's Profile")**
- [![toninom's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37813-toninom "View toninom's Profile") Topic Author
- [ Offline](/forum/user/37813-toninom)

Less More

- Posts: 23
- Thank you received: 0
-
-

11 years 1 month ago [\#215292](#215292) by [toninom](/forum/user/37813-toninom "View toninom's Profile")  Replied by *[toninom](/forum/user/37813-toninom "View toninom's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215292 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

Thanks but it doesn't work, I miss something for sure, this is my code : Code:

&lt;?php define( '_JEXEC', 1); // This will allow to access file outside of joomla. define( 'DS', DIRECTORY_SEPARATOR ); define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) ); require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); $mainframe =&amp; JFactory::getApplication('site'); $mainframe-&gt;initialise(); $user = JFactory::getUser(); $session =&amp; JFactory::getSession(); $database = JFactory::getDBO(); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')) return true; $app = JFactory::getApplication(); $order_id = $app-&gt;getUserState('com_hikashop.order_id'); if (!$order_id) die("Nessun id ordine"); //GET IVA $query = $database-&gt;getQuery(true); $query-&gt;select('tax_rate'); $query-&gt;from($database-&gt;quoteName('#__hikashop_tax')); $query-&gt;where($database-&gt;quoteName('tax_namekey')." = ".$database-&gt;quote('IVA')); $database-&gt;setQuery($query); $iva = $database-&gt;loadResult(); $orderClass = hikashop_get('class.order'); $orderProductClass = hikashop_get('class.order_product'); $fullorder = $orderClass-&gt;loadFullOrder($order_id,false,false); $input = new JInput; $post_array = $input-&gt;getArray($_GET); $prodotto = new stdClass(); $prodotto-&gt;order_product_id = $post_array[$id]; $prodotto-&gt;order_product_quantity = 1; $prodotto-&gt;order_product_price = 100; $products = array ($prodotto); $orderProductClass-&gt;save($products);

By the way, about recalculatefullprice, I pass it a good object, checked by var_dump before the call, but inside the function is NULL, what's wrong?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

11 years 1 month ago [\#215303](#215303) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215303 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

Hi,

The save function of orderProductClass is to add new order_products, not to update existing ones.
For existing ones, you want to use instead the update function of orderProductClass and in that case, it's the product object that you want to pass to the function.

For the recalculatefullprice function, I don't know what code you're using to call it so I can't say much more.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[toninom](/forum/user/37813-toninom "View toninom's Profile")**
- [![toninom's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37813-toninom "View toninom's Profile") Topic Author
- [ Offline](/forum/user/37813-toninom)

Less More

- Posts: 23
- Thank you received: 0
-
-

11 years 1 month ago -  11 years 1 month ago [\#215391](#215391) by [toninom](/forum/user/37813-toninom "View toninom's Profile")  Replied by *[toninom](/forum/user/37813-toninom "View toninom's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215391 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

> nicolas wrote: Hi,
>
> The save function of orderProductClass is to add new order\_products, not to update existing ones.
> For existing ones, you want to use instead the update function of orderProductClass and in that case, it's the product object that you want to pass to the function.
>
> For the recalculatefullprice function, I don't know what code you're using to call it so I can't say much more.

Ok, let's recap. Nobody told me about this update function, since the start everyone has written about the save function, I'm a little confused.
WHAT I DID AND WHAT I NEED TO DO:

- I edited end.php with a form to let the user write the new price of every product in order, the form sends this data to a save.php, it passes order\_product\_price and order\_product\_id.
- Inside save.php I load joomla and hikashop framework, then with a for I write in a standard class the data passed by the POST, in this way: Code:

for ($i = 0; $i &lt; count ($fullorder-&gt;products); $i++){ $id = "orderidprodotto". $i; $prezzo = "prezzo". $i; $prodottoinordine = $orderProductClass-&gt;get($post_array[$id]); $obj = new stdClass(); $obj-&gt;order_product_id = $post_array[$id]; $obj-&gt;order_id = $prodottoinordine-&gt;order_id; $obj-&gt;product_id = $prodottoinordine-&gt;product_id; $obj-&gt;order_product_quantity = (int) $prodottoinordine-&gt;order_product_quantity; $obj-&gt;order_product_name = $prodottoinordine-&gt;order_product_name; $obj-&gt;order_product_code = $prodottoinordine-&gt;order_product_code; $obj-&gt;order_product_price = (float) $post_array[$prezzo]; $obj-&gt;order_product_tax = (float) $post_array[$prezzo] * $iva; $element[$i]=$obj; }

and put it in an array ($element). $prodottoinordine is an object loaded with the class.order\_product ($prodottoinordine = $orderProductClass-&gt;get($post\_array\[$id\]))
- Now what I need is recalculate all the total and subtotal prices (can recalculatefullprice helps me?) and finally save (update?) my order

Last edit: 11 years 1 month ago by [toninom](/forum/user/37813-toninom "View toninom's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[toninom](/forum/user/37813-toninom "View toninom's Profile")**
- [![toninom's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37813-toninom "View toninom's Profile") Topic Author
- [ Offline](/forum/user/37813-toninom)

Less More

- Posts: 23
- Thank you received: 0
-
-

11 years 1 month ago -  11 years 1 month ago [\#215397](#215397) by [toninom](/forum/user/37813-toninom "View toninom's Profile")  Replied by *[toninom](/forum/user/37813-toninom "View toninom's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215397 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

ok, something works, it needs to update every order_product inside the for, the passed object must have an order_product_id and an order_product_quantity, plus the data to edit, order_product_price and order_product_tax in my case. Hoping this info can helps someone else. EDIT: ok I can directly use the object loaded by order_prodcut class, just modifying price and tax and updating it by the update function (the save function wanted a new object, so I was using a new obj).
Now I need to update the order info, like order_full_price, order_subtotal, order_tax_info, can I use the recalculatefullprice function to automate this action? If yes there is something that I need to know ? Once I recalculate all the total and subtotal, can I use class.order save function? Or there is an update like orderproduct?

You are fantastic and you have a lot of patience , but I have to say it , the documentation is really poor , would be useful more doc about at least the most basic functions .

Last edit: 11 years 1 month ago by [toninom](/forum/user/37813-toninom "View toninom's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

11 years 1 month ago [\#215410](#215410) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215410 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

So, yes, you want to do two things:
- At the end of your loop, you want to add a call to the update function of class.order_product in order to update the order_product entry for each product of the order.
Then, after the loop, you create a $order object with just the order_id set in it and you want to call the recalculatefullprice function of class.order with that $order parameter passed to the function. Then, you want to call the save function of class.order on that $order object (where the full price will have been calculated, in order to store the new full price of the order.

Most of the documentation is orientated to merchants, not developers. And even the developer documentation is orientated to people wanting to integrate HikaShop with other systems via plugins. For what you're trying to do, yes the documentation is really poor because it's not our target, unfortunately.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[toninom](/forum/user/37813-toninom "View toninom's Profile")**
- [![toninom's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/37813-toninom "View toninom's Profile") Topic Author
- [ Offline](/forum/user/37813-toninom)

Less More

- Posts: 23
- Thank you received: 0
-
-

11 years 1 month ago [\#215430](#215430) by [toninom](/forum/user/37813-toninom "View toninom's Profile")  Replied by *[toninom](/forum/user/37813-toninom "View toninom's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215430 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

Thanks, now all seems to work. I just add this code for the order product tax info : Code:

$tasse = unserialize($prodottoinordine-&gt;order_product_tax_info); $tasse[0]-&gt;tax_amount = $prodottoinordine-&gt;order_product_tax; $prodottoinordine-&gt;order_product_tax_info = serialize($tasse);

Is it right ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

11 years 4 weeks ago [\#215459](#215459) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product price editable on checkout](/forum/27-checkout/878607-product-price-editable-on-checkout?start=20#215459 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.3 -- PHP version -- : 5.4 -- Browser(s) name and version -- : Chrome  I don't know if there is an easy way to do this, but as I wrote on title I need to get editable the product price on checkout page. I checked cart.php but it'ìs a little hard to understand where I need to edit the code.  This seems to print the price, but I don't know where &quot;CART&#95;PRODUCT&#95;UNIT&#95;PRICE&quot; is formatted thanks in advance")*

Yes, that should be enough.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3ODYwNy1wcm9kdWN0LXByaWNlLWVkaXRhYmxlLW9uLWNoZWNrb3V0P3N0YXJ0PTIwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.244 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
