- Posts: 128
- Thank you received: 3
Update product total price with quantity & option
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3.24
I have created a product that has multiple prices based on quantity (see attached screenshot). I have found a way to display the prices based on the minimum quantities instead of per unit by editing Hikashop->Display->Views->product/listing_price.php where it has:
To:
The problem I'm having is when you land on the page I would like it to show the price for 250 next to "Price with options:" instead of $0.00. I then also need it to update that price on quantity change and option change. For instance:
quantity of 500 with option as yes would display $65.00
quantity of 2000 with option as no would display $200.00
etc.
Right now the price is not updating at all, except if you change the option and then it is per unit ($0.02). What do I need to edit to make this happen.
Please Log in or Create an account to join the conversation.
There is no system to take into account the quantity entered in the display of the price.
That will require complex javascript code to be added to the view.
Mainly in the "option" view file (to have the "price with options" calculus take into account the quantity) but also in the "show_quantity" view file (to have the modification of the quantity input trigger the recalculation of the price with options).
Please Log in or Create an account to join the conversation.
edit: I just did some digging and I noticed that the input id="hikashop_price_product_158" value="0" (see attached screenshot).
I think this may be part of the problem because I would think the value should = 0.12. Am I wrong?
Please Log in or Create an account to join the conversation.
1. That's correct.
2. The hikashopChangeOption function will display the price of the unit price of the product with all the options unit price added up. So it takes into account the options you selected and the variants selected, but not the quantity you entered. You can see an example on our demo website here:
demo.hikashop.com/index.php/en/hikashop/...ct-page/with-options
Please Log in or Create an account to join the conversation.
deuce4884 wrote:
edit: I just did some digging and I noticed that the input id="hikashop_price_product_158" value="0" (see attached screenshot).
I think this may be part of the problem because I would think the value should = 0.12. Am I wrong?
For some reason the appropriate unit price is not in that input's value. Sorry to be such a bother but I really need to figure out a way to make this work and update based on quantity and option. Your help is greatly appreciated.
Please Log in or Create an account to join the conversation.
Why is it if($price->price_min_quantity<=1)? This is the reason I'm getting 0 as a value for the input I mentioned earlier in this thread. For this product all values of $price->price_min_quantity are greater than 1. They are 250, 500, 1000. Maybe I'm just missing something here though.
Please Log in or Create an account to join the conversation.
As I said, the system uses the unit price. As you didn't enter any on your product, you get that result.
Add a new price line with a min qty of 1 in your product and you'll see that the system will take it.
If you want to change the code there to use another price_min_quantity, you can do it, but again, the system isn't made to update the base price when you change the quantity of the product, so even though it might be a bit better it won't be perfect on your website with the way your products are configured.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Yes, this would work.
Regarding the javascript code, you can add it to one of the files of the product view.
The best is to do it via the menu Display>Views of HikaShop (for example, in the show_default view file). When you change stuff there, the changes are saved as view overrides so you won't loose them when you update HikaShop.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
The ajax call seems fine and I don't see any js error.
So there must be an issue with the if:
if(qty && price_id){
either qty or price_id are false and thus the ajax call is not done.
I would recommend to add some alerts there to see what is in these variables and go from there.
Please Log in or Create an account to join the conversation.
I just thought you may want to know where I stand on this issue we've been working on. For security reasons I developed an Ajax plugin and now have it functioning as I intended. It's kind of a round about way to do something but it works. I have attached the plugin to this post, so you can check that out and any of the product pages i mentioned earlier in the thread. Notes about everything are in the installation.txt file. Thanks for all your help and pointing me in the right direction.
Please log in or register to see it.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Sorry the plugin isn't working for you. I'm assuming you are using the latest versions of Joomla and Hikashop Business. The plugin was developed on Joomla 3.4.1 and Hikashop 2.5.4. I did not have to do any special admin configuration to make it work. However, I have worked on some of the javascript functions for this plugin to allow it to work for products that have characteristics and options and have just finished putting together the new install instructions. I have attached the new version to this post. So, if you want remove the old version including all the view customizations you made and install the new version and go through the new install instructions. If it still doesn't work reply back with a webpage that's giving you problems and I'll try to help.
Please log in or register to see it.
Please Log in or Create an account to join the conversation.
Line 20 : var variant=variantId.split('_');
Please Log in or Create an account to join the conversation.
but i don't see where
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
But still not working, nothing happen when i select the quantity... to sad...
Really thank you for what you've done so far.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Here the link : creasavoie.com/levivier/drive-en-ligne/p...-blanc-de-ligne.html
Please Log in or Create an account to join the conversation.