Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $db, $vbulletin, $vbphrase, $small_cart, $small_cart_products;
- require_once('./vbbcart/functions.php');
- $currency = $vbulletin->options['table_currency'];
- $userid = $vbulletin->userinfo['userid'];
- $products = $db->query_read("
- SELECT *
- FROM ".TABLE_PREFIX."table_carts
- WHERE userid=$userid
- ORDER BY price ASC
- ");
- $cart_products = "";
- $price = 0;
- $discount = 0;
- $totalprice = 0;
- $totaldiscount = 0;
- $finalprice = 0;
- $coupondiscount = 0;
- while($product = $db->fetch_array($products))
- {
- $usercoupon = $db->query_first("
- SELECT *
- FROM " . TABLE_PREFIX ."table_usercoupon
- WHERE userid=$userid
- AND valid=1
- ");
- if(!empty($usercoupon))
- {
- $cupdiscount = $db->query_first("
- SELECT *
- FROM " . TABLE_PREFIX ."table_coupon
- WHERE cpid=$usercoupon[cpid]
- AND prodid=$product[productid]
- ");
- $coupondiscounta = $cupdiscount[cpprice];
- $coupondiscount += $coupondiscounta;
- $price = $product["price"];
- $discount = $product["discount"];
- $totalprice += $price;
- $totaldiscount += $discount;
- } else {
- $price = $product["price"];
- $discount = $product["discount"];
- $totalprice += $price;
- $totaldiscount += $discount;
- }
- $templater = vB_Template::create('small_cart_products');
- $templater->register('id', $product[id]);
- $templater->register('name', stripslashes($product[productname]));
- $templater->register('price', getFormatPrice($price));
- $templater->register('discount', getFormatPrice($discount));
- $templater->register('quantity', $product[quantity]);
- $small_cart_products .= $templater->render();
- }
- $finalprice = $totalprice - $totaldiscount - $coupondiscount;
- $totalprice = getFormatPrice($totalprice);
- $totaldiscount = getFormatPrice($totaldiscount);
- $finalprice = getFormatPrice($finalprice);
- //Mini Cart
- $templater = vB_Template::create('small_cart');
- $templater->register('small_cart_products', $small_cart_products);
- $templater->register('totalprice', $totalprice);
- $templater->register('totaldiscount', $totaldiscount);
- $templater->register('coupondiscount', $coupondiscount);
- $templater->register('finalprice', $finalprice);
- $small_cart .= $templater->render();
- ?>
Add Comment
Please, Sign In to add comment