CubeCartForums.org Documentation Area

CubeCartForums.org for CubeCart third-party documentation, modifications, skins and services
Permanent Link   Print This Page
Introduction CubeCart v3 CubeCart v4 CubeCart v5 Appendix Search

CubeCart Version 3 Documentation - Adding 'Add' and 'More' buttons to the Latest Products

Google Translate:

Adding 'Add' and 'More' buttons to the Latest Products

Easy Method

This is a simple modification to add 'buy' and 'more' buttons to the front page latest products. It does not use the langiage file for the button text, therefore eliminates the need to modify core CubeCart files on upgrade.

Edit:

/skins/SKIN_NAME/styleTemplates/content/index.tpl


Search for:
</div>
<!-- END: repeat_prods -->

And paste this just before, or where ever you would like to have the buttons:
<form action="index.php" method="post" name="prod{VAL_PRODUCT_ID}">
<input type="hidden" name="add" value="{VAL_PRODUCT_ID}" />
<input type="hidden" name="quan" value="1" /><a href="javascript:submitDoc('prod{VAL_PRODUCT_ID}');" target="_self" class="txtButton">Buy</a> <a href="index.php?act=viewProd&amp;productId={VAL_PRODUCT_ID}" target="_self" class="txtButton">More</a></form>
To change the text used on the buttons, change the text shown in bold.

This code must be within the repeating area of the latest products area:
<!-- BEGIN: repeat_prods -->
The code in here somewhere.
<!-- END: repeat_prods -->
Save, and upload.

The buttons have standard functionality as on the Categories page, with the following exceptions:
  1. It does not use the language file for button name text, therefore not multi-language compatible.
  2. It assumes that the products are in stock, ie there is no stock control element to the 'buy' button appearing.


Advanced Method

This is the more advanced version which behaves in the same way as the categories page product list. Language and stock control compatible.

Edit:

/skins/SKIN_NAME/styleTemplates/content/index.tpl


Search for:
</div>
<!-- END: repeat_prods -->

And paste this just before, or where ever you would like to have the buttons:
<form action="index.php" method="post" name="prod{VAL_PRODUCT_ID}">
<!-- BEGIN: buy_btn --><input type="hidden" name="add" value="{VAL_PRODUCT_ID}" />
<input type="hidden" name="quan" value="1" /><a href="javascript:submitDoc('prod{VAL_PRODUCT_ID}');" target="_self" class="txtButton">{BTN_BUY}</a><!-- END: buy_btn --> <a href="index.php?act=viewProd&amp;productId={VAL_PRODUCT_ID}" target="_self" class="txtButton">{BTN_MORE}</a></form>
This code must be within the repeating area of the latest products area:
<!-- BEGIN: repeat_prods -->
The code in here somewhere.
<!-- END: repeat_prods -->
Save, and upload.

Edit:

/includes/content/index.inc.php


Search for (around line 48):
$latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 ORDER BY productId DESC LIMIT ".$config['noLatestProds']);

Amend the query to include 'useStockLevel' and 'stock_level', as shown below:
$latestProducts = $db->select("SELECT productId, image, price, name, sale_price, useStockLevel, stock_level FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 ORDER BY productId DESC LIMIT ".$config['noLatestProds']);

Search for (around line 92):
$index->parse("index.latest_prods.repeat_prods");

And paste this just before:
// BEGIN Latest Products Buttons
if($config['outofstockPurchase']==1){

$index->assign("BTN_BUY",$lang['front']['viewCat']['buy']);
$index->assign("VAL_PRODUCT_ID",$latestProducts[$i]['productId']);
$index->parse("index.latest_prods.repeat_prods.buy_btn");

} elseif($latestProducts[$i]['useStockLevel']==1 && $latestProducts[$i]['stock_level']>0){

$index->assign("BTN_BUY",$lang['front']['viewCat']['buy']);
$index->assign("VAL_PRODUCT_ID",$latestProducts[$i]['productId']);
$index->parse("index.latest_prods.repeat_prods.buy_btn");

} elseif($latestProducts[$i]['useStockLevel']==0){

$index->assign("BTN_BUY",$lang['front']['viewCat']['buy']);
$index->assign("VAL_PRODUCT_ID",$latestProducts[$i]['productId']);
$index->parse("index.latest_prods.repeat_prods.buy_btn");

}
$index->assign("BTN_MORE",$lang['front']['viewCat']['more']);
// END Latest Products Buttons
Save, and upload.





Comments, Feedback, Suggestions and Documentation Submissions please post in the Documentation Chat Forum.