- Posts: 23
- Thank you received: 0
Product price editable on checkout
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 or Create an account to join the conversation.
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 or Create an account to join the conversation.
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:
and put it in an array ($element). $prodottoinordine is an object loaded with the class.order_product ($prodottoinordine = $orderProductClass->get($post_array[$id]))Code:for ($i = 0; $i < count ($fullorder->products); $i++){ $id = "orderidprodotto". $i; $prezzo = "prezzo". $i; $prodottoinordine = $orderProductClass->get($post_array[$id]); $obj = new stdClass(); $obj->order_product_id = $post_array[$id]; $obj->order_id = $prodottoinordine->order_id; $obj->product_id = $prodottoinordine->product_id; $obj->order_product_quantity = (int) $prodottoinordine->order_product_quantity; $obj->order_product_name = $prodottoinordine->order_product_name; $obj->order_product_code = $prodottoinordine->order_product_code; $obj->order_product_price = (float) $post_array[$prezzo]; $obj->order_product_tax = (float) $post_array[$prezzo] * $iva; $element[$i]=$obj; }
- Now what I need is recalculate all the total and subtotal prices (can recalculatefullprice helps me?) and finally save (update?) my order
Please Log in or Create an account to join the conversation.
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 .
Please Log in or Create an account to join the conversation.
- 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 or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.