PrestaShop Forums: Random good at empty basket - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


Random good at empty basket


Random good at empty basket

#1 iSlayter

    PrestaShop Newbie

  • 20 Jun 2009
  • Members
  • Pip
  • 10 posts

Posted 21 June 2009 - 09:51 PM

/modules/blockcart/blockcart.php

After:

$smarty->assign(array(
'products'=> $params['cart']->getProducts(true),
'customizedDatas' => Product::getAllCustomizedDatas(intval($params['cart']->id)),
'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_,
'discounts' => $params['cart']->getDiscounts(),
'nb_total_products' =>$params['cart']->nbProducts(),
'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(true, 5), $currency),
'show_wrapping' => floatval($params['cart']->getOrderTotal(true, 6)) > 0 ? true : false,
'wrapping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(true, 6), $currency),
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal(true, 4), $currency),
'total' => Tools::displayPrice($params['cart']->getOrderTotal(), $currency),
'id_carrier' => $params['cart']->id_carrier,
'ajax_allowed' => intval(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false
));


After it add:


$totalProducts = $params['cart']->nbProducts();
if (null == $totalProducts) {
$smarty->assign('randomProduct' ,Db::getInstance()->GetRow('SELECT `id_product`, `name` FROM `' . _DB_PREFIX_ . 'product_lang` ORDER BY RAND()'));
}


/modules/blockcart/blockcart.tpl


{if $cart_qties > 0}
here goes your template if cart not empty
{else}
You may be interested in «{$randomProduct.name}».
{/if}


I think the way I did it is wrong (mixing logic with business logic - we must follow MVC pattern). There must be method getRandom() at classes/Cart.php - but when I id there - how can I call it?

global $cart;
var_dump($cart);

showing not this class :(
my week called "50 first dates with PrestaShop" :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users