♥JcMagpie Posted April 27, 2019 Posted April 27, 2019 JcM Product listing no stock Buy Button 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.
SCH_001 Posted May 21, 2019 Posted May 21, 2019 @JcMagpie Can this be modified so the button changes to red but says Pre-Order without the symbol and still allows the item to be added to the cart? Thanks Troy
♥JcMagpie Posted May 21, 2019 Author Posted May 21, 2019 What something like this, 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.
SCH_001 Posted May 22, 2019 Posted May 22, 2019 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');
♥JcMagpie Posted May 22, 2019 Author Posted May 22, 2019 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.