VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Framar on December 06, 2013, 20:38:47 PM

Title: 2 different span class name for "add to cart button"
Post by: Framar on December 06, 2013, 20:38:47 PM
Hello,

I added a new "add to cart" button in the categories pages. For button's size reasons, I changed the name of span class for button in the categories page from <span class="addtocart-button"> to <span class="addtocart-button-category">.
In this way I can modify size and color of button in the categories page, but the problem is that on those pages the button doesn't work.

I found in vmprices.js the following code: 

product : function(carts) {
carts.each(function(){
var cart = jQuery(this),
step=cart.find('input[name="quantity"]'),
addtocart = cart.find('input.addtocart-button'),
plus   = cart.find('.quantity-plus'),
minus  = cart.find('.quantity-minus'),
select = cart.find('select'),
radio = cart.find('input:radio'),
virtuemart_product_id = cart.find('input[name="virtuemart_product_id[]"]').val(),
quantity = cart.find('.quantity-input');

if I add a row in this code in this way:

product : function(carts) {
carts.each(function(){
var cart = jQuery(this),
step=cart.find('input[name="quantity"]'),
addtocart = cart.find('input.addtocart-button'),
addtocart = cart.find('input.addtocart-button-category'),

plus   = cart.find('.quantity-plus'),
minus  = cart.find('.quantity-minus'),
select = cart.find('select'),
radio = cart.find('input:radio'),
virtuemart_product_id = cart.find('input[name="virtuemart_product_id[]"]').val(),
quantity = cart.find('.quantity-input');

but still doesn't work!
How can I do to make works both button on both pages?  ( categories page and product detail page )
Title: Re: 2 different span class name for "add to cart button"
Post by: GJC Web Design on December 06, 2013, 22:43:57 PM
would it not be simpler to add a 2nd class?

e.g.  <span class="addtocart-button  categorybut">

and target your css

.addtocart-button.categorybut  {
color:green;
}

or simpler still the cat page will have an enclosing div somewhere thats not on the product detail page

#categorypage  .addtocart-button {
color:green;
}

Title: Re: 2 different span class name for "add to cart button"
Post by: Framar on December 08, 2013, 21:04:15 PM
Now it worls, thanks for your help!