Jump to content

Ajax "Add to cart" button in HomeFeatured module?


Recommended Posts

Hello!

Does anybody how to make it right in PS1.5.4.1?

How to make Ajax "Add to cart" button in HomeFeatured module?

 

Im trying compare two files

 

homefeatured.tpl (without Ajax "Add to cart")

{if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE}
   {if ($product.quantity > 0 OR $product.allow_oosp)}
   <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
   {else}
   <span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span>
   {/if}
  {else}
   <div style="height:23px;"></div>
  {/if}

 

with

product-list.tpl (with Ajax "Add to cart")

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

Edited by kisweb (see edit history)

Share this post


Link to post
Share on other sites

Hi,

 

What is your question actually?? Homefeaturedproduct has a button to add a product to cart in AJAX...What is the problem actually? Are you trying to have the same look. Because the button is ACTUALLY using ajax to send product to cart.

 

Martin

Share this post


Link to post
Share on other sites

go to homefeatured.css located in the module directory

 

remove the lines:

#featured-products_block_center li .ajax_add_to_cart_button {display:none;}
#featured-products_block_center li span.exclusive {display:none;}

 

in the homefeatured.tpl add:

{if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE}
   {if ($product.quantity > 0 OR $product.allow_oosp)}
   <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
   {else}
   <span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span>
   {/if}
  {else}
   <div style="height:23px;"></div>
  {/if}

  • Like 1

Share this post


Link to post
Share on other sites
  • 3 months later...

Hey Vekia,

  I was able to change the Text from "Add to cart" to "Buy Now" on product page, But I also want it to appear as Buy Now on Home Featured Home Page. Also please help me to change the yellow color of the Add to Cart button. Please check on link below to understand better.

 

http://gadgetsduniya.abcz8.com/presta/

 

Thanks & Regards,

Santosh

Share this post


Link to post
Share on other sites

hello

 

to change "add to cart" to something other go to localization > translations, from dropdown select installed modules translations, search for "add to cart" and change it to any other text you want

Share this post


Link to post
Share on other sites

hello

 

to change "add to cart" to something other go to localization > translations, from dropdown select installed modules translations, search for "add to cart" and change it to any other text you want

 

Thanks,

And how do I change the button color from yellow to other?

Share this post


Link to post
Share on other sites

if you want to change styles for button, you need to change css styles:

input.button_mini, input.button_small, input.button, input.button_large, input.button_mini_disabled, input.button_small_disabled, input.button_disabled, input.button_large_disabled, input.exclusive_mini, input.exclusive_small, input.exclusive, input.exclusive_large, input.exclusive_mini_disabled, input.exclusive_small_disabled, input.exclusive_disabled, input.exclusive_large_disabled, a.button_mini, a.button_small, a.button, a.button_large, a.exclusive_mini, a.exclusive_small, a.exclusive, a.exclusive_large, span.button_mini, span.button_small, span.button, span.button_large, span.exclusive_mini, span.exclusive_small, span.exclusive, span.exclusive_large, span.exclusive_large_disabled {
position: relative;
display: inline-block;
padding: 5px 7px;
border: 1px solid #cc9900;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
font-weight: bold;
color: #000;
background: url(../img/bg_bt.gif) repeat-x 0 0 #f4b61b;
cursor: pointer;
}

it's a part of global.css file

Share this post


Link to post
Share on other sites
  • 7 months later...

Edit

/modules/blockcart/ajax-cart.js file.

 

line 40 looks like:

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

change it to:

1
ajaxCart.add(idProduct, null, false, this, $('#quantity_to_cart_'+idProduct+'').val());

 

Solution by Vekia

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More