Jump to content

Recommended Posts

A simple add-on to let you display buy button on product list pages. This button will change if stock is zero and prevent the product from being added to cart.

 

This is a CORE file change and will replace your existing files. Do not use if you do not like to change core files.

 

If you are happy to make the changes either compare the file with yours and update your file or Simply copy all files into relevant sections.

image.png.758eb9393145bbf0b58cc8613ec9f61d.png


 

Share this post


Link to post
Share on other sites

What something like this,

image.png.546e92bf410bd26317df658d3ec21bb8.png

 

Sure just edit as you like, The text is in the language file, to enable add to cart just remove the disable class from the button in product_listing file. The symbol is also in the file just remove it.

$prod_list_contents .=  tep_draw_button(OUT_OF_STOCK_STAMP, '', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . ((tep_has_product_attributes((int)$listing['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-danger btn-sm btn-product-listing btn-buy') . PHP_EOL;
        

But remember if you have the product info no stock button active you will need to make the same changes to that also.


 

Share this post


Link to post
Share on other sites

Hi @JcMagpie hoping you don't get sick of all my questions I removed disabled from
$prod_list_contents .=          tep_draw_button(IMAGE_BUTTON_OUT_OF_STOCK, 'fa fa-ban', NULL, NULL, NULL, 'btn-danger btn-product-listing btn-buy');
I can click the button but is does not do anything complete code snippet below from Frozen BS3

if ( tep_get_products_stock($listing['products_id']) > 0 ) {
        $prod_list_contents .=           tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . ((tep_has_product_attributes((int)$listing['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-success btn-product-listing btn-buy');
        } else {
         $prod_list_contents .=          tep_draw_button(IMAGE_BUTTON_OUT_OF_STOCK, 'fa fa-ban', NULL, NULL, NULL, 'btn-danger btn-product-listing btn-buy');

 

Share this post


Link to post
Share on other sites
Posted (edited)

Sure understand your problem, add-on was made for someone who did not wish to have cart active at all so button was replaced with dead button. So to make active to add to cart use this, mod as required. You are basicly adding an active button again.

if ( tep_get_products_stock($listing['products_id']) > 0 ) {
        $prod_list_contents .=           tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . ((tep_has_product_attributes((int)$listing['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-success btn-product-listing btn-buy');
        } else {
$prod_list_contents .=           tep_draw_button(IMAGE_BUTTON_OUT_OF_STOCK, 'fa fa-shopping-cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . ((tep_has_product_attributes((int)$listing['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-danger btn-product-listing btn-buy');
         

You will need to do the same in product_info if you modded that.

Edited by JcMagpie

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×