Guest User

Untitled

a guest
Jan 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. <?php
  2. global $db, $vbulletin, $vbphrase, $small_cart, $small_cart_products;
  3. require_once('./vbbcart/functions.php');
  4.  
  5.     $currency = $vbulletin->options['table_currency'];
  6.   $userid = $vbulletin->userinfo['userid'];
  7.  
  8.   $products = $db->query_read("
  9.     SELECT *
  10.     FROM ".TABLE_PREFIX."table_carts
  11.     WHERE userid=$userid
  12.     ORDER BY price ASC
  13.     ");
  14.  
  15.   $cart_products = "";
  16.   $price = 0;
  17.   $discount = 0;
  18.   $totalprice = 0;
  19.   $totaldiscount = 0;
  20.   $finalprice = 0;
  21.   $coupondiscount = 0;
  22.  
  23.   while($product = $db->fetch_array($products))
  24.   {
  25.         $usercoupon = $db->query_first("
  26.             SELECT *
  27.             FROM " . TABLE_PREFIX ."table_usercoupon
  28.             WHERE userid=$userid
  29.             AND valid=1
  30.             ");
  31.            
  32.         if(!empty($usercoupon))
  33.         {
  34.             $cupdiscount = $db->query_first("
  35.                 SELECT *
  36.                 FROM " . TABLE_PREFIX ."table_coupon
  37.                 WHERE cpid=$usercoupon[cpid]
  38.                 AND prodid=$product[productid]
  39.                 ");
  40.        
  41.             $coupondiscounta = $cupdiscount[cpprice];
  42.             $coupondiscount += $coupondiscounta;
  43.             $price = $product["price"];
  44.             $discount = $product["discount"];
  45.             $totalprice += $price;
  46.             $totaldiscount += $discount;
  47.         } else {           
  48.             $price = $product["price"];
  49.             $discount = $product["discount"];
  50.             $totalprice += $price;
  51.             $totaldiscount += $discount;
  52.         }
  53.  
  54.         $templater = vB_Template::create('small_cart_products');
  55.         $templater->register('id', $product[id]);
  56.         $templater->register('name', stripslashes($product[productname]));
  57.         $templater->register('price', getFormatPrice($price));
  58.         $templater->register('discount', getFormatPrice($discount));
  59.         $templater->register('quantity', $product[quantity]);
  60.         $small_cart_products .= $templater->render();
  61.     }
  62.  
  63.   $finalprice = $totalprice - $totaldiscount - $coupondiscount;
  64.   $totalprice = getFormatPrice($totalprice);
  65.   $totaldiscount = getFormatPrice($totaldiscount);
  66.   $finalprice = getFormatPrice($finalprice);
  67.  
  68.     //Mini Cart
  69.   $templater = vB_Template::create('small_cart');
  70.   $templater->register('small_cart_products', $small_cart_products);
  71.   $templater->register('totalprice', $totalprice);
  72.   $templater->register('totaldiscount', $totaldiscount);
  73.   $templater->register('coupondiscount', $coupondiscount);
  74.   $templater->register('finalprice', $finalprice);
  75.   $small_cart .= $templater->render();
  76. ?>
Add Comment
Please, Sign In to add comment