Jump to content

Ajax add to cart button with product attributes


Recommended Posts

Hi

 

i have the link add to cart button

 

 {if !$PS_CATALOG_MODE && ($product.allow_oosp || $product.stock_quantity > 0)} 


       <a class="exclusive button ajax_add_to_cart_button" href="{$link->getPageLink('cart', true, NULL, "qty=1&id_product={$product.id_product|intval}&token={$static_token}&add")}" rel="ajax_id_product_{$product.id_product|intval}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
      {/if}

 

how to add produt attributes with this link.

 

I have product shirt1 have 35,36,38,40.but i click the link ,cart added oly default product(35 size) . so how to add the produt with attributes

Link to comment
Share on other sites

call to add to cart function looks like:

ajaxCart.add(idProduct, null, false, this);

 

add function has got ajax POST query:

type: 'POST',
  headers: { "cache-control": "no-cache" },
  url: baseUri + '?rand=' + new Date().getTime(),
  async: true,
  cache: false,
  dataType : "json",
  data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
  success: function(jsonData,textStatus,jqXHR)

as you can see, there is no option to define the product attribute, only combination

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Hello please can somenone help me with this issue?  I have put some attributes to products like sizes and when i want to add to cart the sizes doesnt change. Each time the shopping cart adds the first combination from a product. My website is here outlet   . Can anyone look and try to add something to cart and see the problem and tell me what should i do please?  hope for a response...

Edited by lionxshop (see edit history)
Link to comment
Share on other sites

i see that problem is there, when i add product to cart with selected attribute, in cart i see always default combination (not the combination that i selected).

 

i bet that problem is connected to your theme, from where you bought it? can you share a link? 

Link to comment
Share on other sites

  • 11 months later...

Hi,

 

I have a problem since we move to a new server the URL for products is not dispalying the attributes or values

 

on the previous server it used to show at the end of the URL html#/size-12lb/flavour-strawberry where on the new server it is html#/-/- 

 

Any help please

Link to comment
Share on other sites

Sorry i know it sounds dumb but i am newbie to the forum don't know where to start an new topic

 

I did the debug on for the new server and compared that to the old one as i still have access to it.

 

Noticed that $attributesCombinations array values are empty in the new site 

 

  0 => Array (4)     id_attribute => ""     id_attribute_group => ""     attribute => ""     group => ""

 

Thanks for your assitance

Link to comment
Share on other sites

×
×
  • Create New...