News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add to cart, change quantity not working when "show prices" are disabled

Started by Thomas Kuschel, April 19, 2016, 08:41:15 AM

Previous topic - Next topic

Thomas Kuschel

I use the virtuemart as a quote request, so I've disabled the
Show Following Prices>Show Prices
(Check to show prices. If using catalogue functionality, some don't want prices to appear on pages.)
But this has a side effect:
The functionality "add-to-cart" with its quantity change +/- is working only in the catalogue view, but not in the detailed view. Because the javascript "vmprices.js" is not loaded in prductdetails view.

Solution: File "components/com_virtuemart/views/productdetails/view.html.php" at line 337:
Change from: if ($show_prices == '1') {
if (!class_exists('calculationHelper'))
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php');
vmJsApi::jPrice();
}

parent::display($tpl);
    }

to:
if ($show_prices == '1') {
if (!class_exists('calculationHelper'))
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php');
}
vmJsApi::jPrice(); //must be included for add-to-cart functionality

parent::display($tpl);
}


Virtuemart 3.0.14, Joomla 3.5.1

Jumbo!

VirtueMart doed not expect people to checkout or place order without knowing the price.

Even if I consider you specific need you still do not need to alter the view i.e. components/com_virtuemart/views/productdetails/view.html.php.

Open the product details page layout file -

components/com_virtuemart/views/productdetails/tmpl/default.php

OR

templates/YOUR-TEMPLATE/html/com_virtuemart/productdetails/default.php

Find the following codes

defined('_JEXEC') or die('Restricted access');

Replace above by:

defined('_JEXEC') or die('Restricted access');
vmJsApi::jPrice();



PS: Multiple calls to vmJsApi::jPrice(); does not make any difference.

Thomas Kuschel

Hi Jumbo,
QuoteDear VirtueMart doed not expect people to checkout or place order without knowing the price.

If you want to have this behavior, you should also disable the functionality "place order" in the catalog view of virtuemart. But it makes no sence IMHO, to support the button "Add to Cart" and the +/- Counter both at the catalogue's view and to the detail's view, but only working at catalogue view.  This IS a bug.
So you are not correct, to place this function into the template itself.
I use virtuemart as a quote request (not showing any prices) since 2009 and I MUST put products into the cart (without prices) - your approach is not correct.

Jumbo!

Quote from: Thomas Kuschel on April 20, 2016, 08:27:37 AM
Your approach is not correct.

It is not my approach. I am just a VirtueMart user like you and I do not agree with you.

Since you are using VirtueMart from 2009, you must be aware that vmJsApi::jPrice(); was earlier called in the layout file itself and you can continue doing so if you need.

Thomas Kuschel

Hi Jumbo!
I can't agree with your approach, but I do understand your intention for a solution.
Your solution do work, and very thanks for your nice response! -  but my intention is also to correct the strange behavior of using standard (default) settings without using overrides.
Again, the view at category like at components/com_virtuemart/views/category/view.html.php  LINE 154 is
// add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
vmJsApi::jPrice();

and with the File components/com_virtuemart/views/productdetails/view.html.php" at line 337 there is
if ($show_prices == '1') {
if (!class_exists('calculationHelper'))
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php');
vmJsApi::jPrice();
}

parent::display($tpl);

which is not the same, and different. Per design, this breaks the "default" (and without overrides) behavior.
And I know to fix it in templates as well. But this is much more a bug in the standard behavior:
vmJsApi::jPrice() is called every time in the catalog view; but not in the productdetails.
Nevertheless, this should be fixed there, my honest suggestion for the virtuemart development:
components/com_virtuemart/views/productdetails/view.html.php" at line 337
if ($show_prices == '1') {
if (!class_exists('calculationHelper'))
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php');
}
vmJsApi::jPrice();
parent::display($tpl);


Thomas

Milbo

I agree with Thomas, even Jumbo has a good point. And Jumbos solutions is also the right way to go.

But we have the functionality "catalogue mode", which disables the add to cart. I also like the idea to use the cart for requesting a quote. and the idea to spare the js is almost not existent, because most users browse it from the category and had loaded it anyway, and even not, the productdetails view is usually very performant.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Thomas Kuschel

Hi Milbo, nice to see you!
You're right, we mainly use the catalogue view only (adding to the cart). But I have some external links to products, and the link goes straight to the detail's view, to add things to the cart. Thank you for your response.
And I agree with you, to use the template overrides too, but there is no reason, not to load the js in the details view.... It's just a small patch, and it works out of the box.
Thomas

lindapowers

Does the catalogue mode still hide the dropdown with child products? Cause that is very nasty for SEO.

When we are on holiday instead of setting the shop to catalogue mode we had to set each product with stock 0.

Regards