Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function procat($productid)
- {
- //Config area//
- //Here we will set the values used throughout the function.
- $Cat1 = '29';
- $Cat2 = '30';
- $Cat3 = '28';
- $Cat4 = '31';
- $Cat5 = '33';
- //NIEUWCATTOE
- //End of config
- $nocat1 = '0';
- $nocat2 = '0';
- $nocat3 = '0';
- $nocat4 = '0';
- $nocat5 = '0';
- //End of setting values
- $resultcheckcat1 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat1);
- $resultcheckcat2 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat2);
- $resultcheckcat3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat3);
- $resultcheckcat4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat4);
- $resultcheckcat5 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat5);
- //Check voor item 1
- if($resultcheckcat1 == '1')
- {
- $element = "item1-" . $productid;
- //Hier maakt hij een element zichtbaar\\
- echo "<script type='text/javascript'>document.getElementById('$element').style.display = 'block';</script>";
- CartControllerCore::cart($productid, '29');
- }
- elseif ($resultcheckcat1 == '0') {
- $nocat1 = '1';
- }
- elseif ($resultcheckcat1 >= '2') {
- $ERROR = "true";
- }
- //Check voor item 2
- if($resultcheckcat2 == '1')
- {
- $element2 = "item2-" . $productid;
- echo "<script type='text/javascript'>document.getElementById('$element2').style.display = 'block';</script>";
- CartControllerCore::cart($productid, '30');
- }
- elseif ($resultcheckcat2 == '0') {
- $nocat2 = '1';
- }
- elseif ($resultcheckcat2 >= '2') {
- $ERROR = "true";
- }
- //Check voor item 3
- if($resultcheckcat3 == '1')
- {
- $element3 = "item3-" . $productid;
- echo "<script type='text/javascript'>document.getElementById('$element3').style.display = 'block';</script>";
- CartControllerCore::cart($productid, '28');
- }
- if($resultcheckcat3 == '0') {
- $nocat3 = '1';
- }
- elseif ($resultcheckcat3 >= '2') {
- $ERROR = "true";
- }
- //Check voor item 4
- if($resultcheckcat4 == '1')
- {
- $element4 = "item4-" . $productid;
- echo "<script type='text/javascript'>document.getElementById('$element4').style.display = 'block';</script>";
- CartControllerCore::cart($productid, '31');
- }
- if($resultcheckcat4 == '0') {
- $nocat4 = '1';
- }
- elseif ($resultcheckcat4 >= '2') {
- $ERROR = "true";
- }
- //Check voor item 5
- if($resultcheckcat5 == '1')
- {
- $element5 = "item5-" . $productid;
- echo "<script type='text/javascript'>document.getElementById('$element5').style.display = 'block';</script>";
- CartControllerCore::cart($productid, '33'); // Let op dat je de goede pakt. Check in backend nogmaals voor productid om zeker te zijn
- }
- if($resultcheckcat5 == '0') {
- $nocat5 = '1';
- }
- elseif ($resultcheckcat5 >= '2') {
- $ERROR = "true";
- }
- //FUNCTIEPROCAT
- if($nocat3 == '1' && $nocat2 == '1' && $nocat1 == '0' && $nocat4 == '0'){
- $elementnocat = "cart-item-" . $productid;
- echo "<script type='text/javascript'>document.getElementById('$elementnocat').style.display = 'none';</script>";
- }
- return '';
- }
- public static function clean($productid, $cat, $cart)
- {
- $resultcheckcat = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$cat);
- if ($resultcheckcat == '1')
- {
- $option = 1;
- $data = array(
- 'cart_id' => $cart,
- 'product_id' => $productid,
- 'option_id' => $option,
- 'cat_id' => $cat,
- );
- Db::getInstance()->insert('attribute_cart_print', $data);
- $context = Context::getContext();
- $cart = $context->cart;
- if($cat == '30'){
- $cart->updateQty(1, 23);
- }elseif ($cat == '29') {
- $cart->updateQty(1, 22);
- }elseif ($cat == '28') {
- $cart->updateQty(1, 24);
- }elseif ($cat == '31') {
- $cart->updateQty(1, 27);
- }
- if ($cat == '33') {
- $cart->updateQty(1, 27);
- }
- //CLEANFUNCTION
- echo "<script>location.reload();</script> ";
- }
- return '';
- }
- public static function check($productid, $Cat)
- {
- $resultcheckcat = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat);
- if ($resultcheckcat == '1') {
- return '1';
- }
- else {
- return '0';
- }
- }
- public static function getprijs($cat)
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$cat);
- $prijs = $row['price'];
- $prijs = $prijs / 100 * 121;
- return (float)$prijs;
- }
- public static function testfunctie1($productid)
- {
- //$context = Context::getContext();
- //$cartid = $context->cart->id;
- //$Cat3 = '28';
- //Deze functie wordt gebruikt om te testen. :)
- //$result = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat3.' AND cart_id = '.$cartid.' AND product_id = '.$product);
- return '';
- }
- public static function delete($productid)
- {
- //Config area//
- //Here we will set the values used throughout the function.
- $Cat1 = '29';
- $Cat2 = '30';
- $Cat3 = '28';
- $Cat4 = '31';
- $Cat5 = '33';
- //variable1
- //End of config
- $foto = '22';
- $voor = '23';
- $service = '24';
- $zwart = '26';
- $kleur = '27';
- //variable2
- //End of setting values
- $resultcheckcat1 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat1);
- $resultcheckcat2 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat2);
- $resultcheckcat3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat3);
- $resultcheckcat4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat4);
- $resultcheckcat5 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat5);
- //sqldelete
- //Check voor item 3
- $context = Context::getContext();
- $cart_products = $context->cart->getProducts();
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $service)
- {
- if($resultcheckcat3 == '1')
- {
- $cartid = $context->cart->id;
- $result3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat3.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($result3 == '1')
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat3.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- $cart->updateQty(0, $service);
- $cart->updateQty($newquantity, $service);
- }
- }
- }
- if($cart_product['id_product'] == $voor)
- {
- if($resultcheckcat2 == '1')
- {
- $cartid = $context->cart->id;
- $result2 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat2.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($result2 == '1')
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat2.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- $cart->updateQty(0, $voor);
- $cart->updateQty($newquantity, $voor);
- }
- }
- }
- if($cart_product['id_product'] == $foto)
- {
- if($resultcheckcat1 == '1')
- {
- $cartid = $context->cart->id;
- $result1 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat1.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($result1 == '1')
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat1.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- $cart->updateQty(0, $foto);
- $cart->updateQty($newquantity, $foto);
- }
- }
- }
- //tbd
- if($cart_product['id_product'] == $zwart)
- {
- if($resultcheckcat4 == '1')
- {
- $cartid = $context->cart->id;
- $result4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat4.' AND cart_id = '.$cartid.' AND option_id = 2 AND product_id = '.$productid);
- if($result4 == '1')
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat4.' AND option_id = 2 AND cart_id = '.$cartid.' AND product_id = '.$productid);
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- $cart->updateQty(0, $foto);
- $cart->updateQty($newquantity, $zwart);
- }
- }
- }
- //tbd
- if($cart_product['id_product'] == $kleur)
- {
- if($resultcheckcat4 == '1')
- {
- $cartid = $context->cart->id;
- $result5 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat4.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($result5 == '1')
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat4.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- $cart->updateQty(0, $kleur);
- $cart->updateQty($newquantity, $kleur);
- }
- }
- }
- if($cart_product['id_product'] == $kleur)
- {
- if($resultcheckcat5 == '1')
- {
- $cartid = $context->cart->id;
- $result6 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat5.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($result6 == '1')
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat5.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- $cart->updateQty(0, $kleur);
- $cart->updateQty($newquantity, $kleur);
- }
- }
- }
- //FUNCTIONDELETE
- }
- //Ivm met designer moet dit gebeuren
- $cart->updateQty(0, $productid);
- // here we need to make a check which deletes all remaining option 2's with product.id / cart->id
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $result = Db::getInstance()->executeS('SELECT * FROM ps_attribute_cart_print WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND option_id = 2 ');
- foreach($result as $row)
- {
- $id = $row['id'];
- Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
- }
- echo "<script>location.reload();</script> ";
- }
- public static function onclick($click)
- {
- if($click == 'optie1')
- {
- $productid = Tools::getValue('optie1');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '29';
- $pro = '22';
- $resultoptie1 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND option_id = 2 AND product_id = '.$productid.' AND cart_id = '.$cartid);
- if($resultoptie1 == '1')
- {
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 1 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 2 ';
- Db::getInstance()->execute($sql);
- $cart = $context->cart;
- $cart->updateQty(1, $pro);
- }
- }
- if($click == 'optie2')
- {
- $productid = Tools::getValue('optie2');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '29';
- $pro = '22';
- $resultoptie2 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($resultoptie2 == '1')
- {
- $cart_products = $context->cart->getProducts();
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 2 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 1 ';
- Db::getInstance()->execute($sql);
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $pro)
- {
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- if($newquantity == '0')
- {
- $cart->updateQty(0, $pro);
- }
- else
- {
- $cart->updateQty(0, $pro);
- $cart->updateQty($newquantity, $pro);
- }
- }
- }
- }
- }
- if($click == 'optie3')
- {
- $productid = Tools::getValue('optie3');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '30';
- $pro = '23';
- $resultoptie3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND option_id = 2 AND product_id = '.$productid.' AND cart_id = '.$cartid);
- if($resultoptie3 == '1')
- {
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 1 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 2 ';
- Db::getInstance()->execute($sql);
- $cart = $context->cart;
- $cart->updateQty(1, $pro);
- }
- }
- if($click == 'optie4')
- {
- $productid = Tools::getValue('optie4');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '30';
- $pro = '23';
- $resultoptie4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($resultoptie4 == '1')
- {
- $cart_products = $context->cart->getProducts();
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 2 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 1 ';
- Db::getInstance()->execute($sql);
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $pro)
- {
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- if($newquantity == '0')
- {
- $cart->updateQty(0, $pro);
- }
- else
- {
- $cart->updateQty(0, $pro);
- $cart->updateQty($newquantity, $pro);
- }
- }
- }
- }
- }
- if($click == 'optie5')
- {
- $productid = Tools::getValue('optie5');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '28';
- $pro = '24';
- $resultoptie3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND option_id = 2 AND product_id = '.$productid.' AND cart_id = '.$cartid);
- if($resultoptie3 == '1')
- {
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 1 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 2 ';
- Db::getInstance()->execute($sql);
- $cart = $context->cart;
- $cart->updateQty(1, $pro);
- }
- }
- if($click == 'optie6')
- {
- $productid = Tools::getValue('optie6');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '28';
- $pro = '24';
- $resultoptie4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($resultoptie4 == '1')
- {
- $cart_products = $context->cart->getProducts();
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 2 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 1 ';
- Db::getInstance()->execute($sql);
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $pro)
- {
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- if($newquantity == '0')
- {
- $cart->updateQty(0, $pro);
- }
- else
- {
- $cart->updateQty(0, $pro);
- $cart->updateQty($newquantity, $pro);
- }
- }
- }
- }
- }
- if($click == 'optie7')
- {
- $productid = Tools::getValue('optie7');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '31';
- $pro1 = '27';
- $pro2 = '26';
- $resultoptie3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND option_id = 2 AND product_id = '.$productid.' AND cart_id = '.$cartid);
- if($resultoptie3 == '1')
- {
- $cart_products = $context->cart->getProducts();
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 1 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 2 ';
- Db::getInstance()->execute($sql);
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $pro2)
- {
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- if($newquantity == '0')
- {
- $cart->updateQty(0, $pro2);
- }
- else
- {
- $cart->updateQty(0, $pro2);
- $cart->updateQty($newquantity, $pro2);
- }
- }
- }
- $cart = $context->cart;
- $cart->updateQty(1, $pro1);
- }
- }
- if($click == 'optie8')
- {
- $productid = Tools::getValue('optie8');
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $cat = '31';
- $pro1 = '27';
- $pro2 = '26';
- $resultoptie4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$cat.' AND cart_id = '.$cartid.' AND option_id = 1 AND product_id = '.$productid);
- if($resultoptie4 == '1')
- {
- $cart_products = $context->cart->getProducts();
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET option_id = 2 WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND cat_id = '.$cat.' AND option_id = 1 ';
- Db::getInstance()->execute($sql);
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $pro1)
- {
- $quantity = $cart_product['cart_quantity'];
- $newquantity = $quantity - 1;
- $cart = $context->cart;
- if($newquantity == '0')
- {
- $cart->updateQty(0, $pro1);
- }
- else
- {
- $cart->updateQty(0, $pro1);
- $cart->updateQty($newquantity, $pro1);
- }
- }
- }
- $cart = $context->cart;
- $cart->updateQty(1, $pro2);
- }
- }
- //ONCLICK22
- return '';
- }
- public static function detailedtotal()
- {
- $context = Context::getContext();
- $cart_products = $context->cart->getProducts();
- foreach ($cart_products as $cart_product)
- {
- $foto = '22';
- $voor = '23';
- $service = '24';
- $zwart = '26';
- $kleur = '27';
- //variable totals
- if($cart_product['id_product'] == $foto)
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$foto);
- $prijs = $row['price'];
- $quantity = $cart_product['cart_quantity'];
- $prijs = $prijs / 100 * 121;
- $prijs = Tools::ps_round($prijs,2);
- echo "<div class='cart-summary-line'>
- <span class='label'>";
- echo $quantity;
- echo " x Drukken foto";
- echo "</span>";
- echo "<span class='value'>";
- echo $quantity;
- echo "x € ";
- echo (float)$prijs;
- echo "<script>
- document.write(parseFloat($prijs).toFixed(2));
- </script>";
- echo "</span>
- </div>";
- }
- if($cart_product['id_product'] == $voor)
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$voor);
- $prijs = $row['price'];
- $quantity = $cart_product['cart_quantity'];
- $prijs = $prijs / 100 * 121;
- $prijs = Tools::ps_round($prijs,2);
- echo "<div class='cart-summary-line'>
- <span class='label'>";
- echo $quantity;
- echo " x Drukken voorkant";
- echo "</span>";
- echo "<span class='value'>";
- echo $quantity;
- echo "x € ";
- echo (float)$prijs;
- echo "</span>
- </div>";
- }
- if($cart_product['id_product'] == $service)
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$service);
- $prijs = $row['price'];
- $quantity = $cart_product['cart_quantity'];
- $prijs = $prijs / 100 * 121;
- $prijs = Tools::ps_round($prijs,2);
- echo "<div class='cart-summary-line'>
- <span class='label'>";
- echo $quantity;
- echo " x In elkaar zet service:";
- echo "</span>";
- echo "<span class='value'>";
- echo $quantity;
- echo "x € ";
- echo (float)$prijs;
- echo "</span>
- </div>";
- }
- if($cart_product['id_product'] == $zwart)
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$zwart);
- $prijs = $row['price'];
- $quantity = $cart_product['cart_quantity'];
- $prijs = $prijs / 100 * 121;
- $prijs = Tools::ps_round($prijs,2);
- echo "<div class='cart-summary-line'>
- <span class='label'>";
- echo $quantity;
- echo " x Drukken zwart:";
- echo "</span>";
- echo "<span class='value'>";
- echo $quantity;
- echo "x € ";
- echo (float)$prijs;
- echo "</span>
- </div>";
- }
- if($cart_product['id_product'] == $kleur)
- {
- $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$kleur);
- $prijs = $row['price'];
- $quantity = $cart_product['cart_quantity'];
- (float)$prijs = $prijs / 100 * 121;
- $prijs = Tools::ps_round($prijs,2);
- echo "<div class='cart-summary-line'>
- <span class='label'>";
- echo $quantity;
- echo " x Drukken kleur:";
- echo "</span>";
- echo "<span class='value'>";
- echo $quantity;
- echo "x € ";
- echo (float)$prijs;
- echo "</span>
- </div>";
- }
- //PLAKHIERBOVEN
- }
- return '';
- }
- public static function cart($productid, $cat)
- {
- $context = Context::getContext();
- $cart = $context->cart->id;
- $result = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE `product_id` = '.(int)$productid.' AND `cart_id` = '.(int)$cart.' AND `cat_id` = '.$cat);
- if($result == '1')
- {
- }else {
- CartControllerCore::clean($productid, $cat, $cart);
- }
- return '';
- }
- public static function opstart($productid)
- {
- $context = Context::getContext();
- $cartid = $context->cart->id;
- $Cat1 = '29';
- $Cat2 = '30';
- $Cat3 = '28';
- $Cat4 = '31';
- $Cat5 = '33';
- //OPSTART1
- $result = Db::getInstance()->executeS('SELECT * FROM ps_attribute_cart_print WHERE cart_id = '.$cartid.' AND product_id = '.$productid);
- foreach($result as $row)
- {
- $id = $row['option_id'];
- $cat = $row['cat_id'];
- if($cat == '28')
- {
- if($id == '1')
- {
- echo "<script>
- var element = document.getElementById('optie5-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- elseif ($id == '2')
- {
- echo "<script>
- var element = document.getElementById('optie6-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- }
- if($cat == '29')
- {
- if($id == '1')
- {
- echo "<script>
- var element = document.getElementById('optie1-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- elseif ($id == '2')
- {
- echo "<script>
- var element = document.getElementById('optie2-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- }
- if($cat == '30')
- {
- if($id == '1')
- {
- echo "<script>
- var element = document.getElementById('optie3-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- elseif ($id == '2')
- {
- echo "<script>
- var element = document.getElementById('optie4-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- }
- if($cat == '31')
- {
- if($id == '1')
- {
- echo "<script>
- var element = document.getElementById('optie7-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- elseif ($id == '2')
- {
- echo "<script>
- var element = document.getElementById('optie8-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- }
- if($cat == '33')
- {
- if($id == '1')
- {
- echo "<script>
- var element = document.getElementById('optie9-".$productid."');
- element.classList.remove('btnselect');
- element.classList.add('btnselects');
- </script>";
- }
- }
- //OPSTART2
- }
- return '';
- }
- public static function leegcheck()
- {
- $context = Context::getContext();
- $cart_products = $context->cart->getProducts();
- $count = 0;
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] != 27 && $cart_product['id_product'] != 26 && $cart_product['id_product'] != 24 && $cart_product['id_product'] != 23 && $cart_product['id_product'] != 22)
- {
- $count + 1;
- }
- }
- if($count == 0)
- {
- $context->cart->delete();
- }
- return '';
- }
- public static function service()
- {
- $context = Context::getContext();
- $cart_products = $context->cart->getProducts();
- $context->cart->updateQty(0, 24);
- foreach ($cart_products as $cart_product)
- {
- $productid = $cart_product['id_product'];
- $categorie = '28';
- $cart = $context->cart->id;
- if($cart_product['id_product'] != 27 && $cart_product['id_product'] != 26 && $cart_product['id_product'] != 24 && $cart_product['id_product'] != 23 && $cart_product['id_product'] != 22)
- {
- $result = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE `product_id` = '.(int)$productid.' AND `cart_id` = '.(int)$cart.' AND `cat_id` = '.$categorie);
- if($result == '1')
- {
- $quantity = $cart_product['cart_quantity'];
- $context->cart->updateQty($quantity, 24);
- $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET ammount = '.$quantity.' WHERE cart_id = '.$cart.' AND product_id = '.$productid.' AND cat_id = '.$categorie.'';
- Db::getInstance()->execute($sql);
- }
- }
- }
- return '';
- }
- public static function up($productid)
- {
- $context = Context::getContext();
- $cart_products = $context->cart->getProducts();
- $cart_products = $context->cart->getProducts();
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $productid)
- {
- $custom = $cart_product['id_customization'];
- }
- }
- $context->cart->updateQty(1, $productid, 0, $customization = $custom, $operator = 'up');
- return '';
- }
- public static function down($productid)
- {
- $context = Context::getContext();
- $cart_products = $context->cart->getProducts();
- $cart_products = $context->cart->getProducts();
- foreach ($cart_products as $cart_product)
- {
- if($cart_product['id_product'] == $productid)
- {
- $custom = $cart_product['id_customization'];
- }
- }
- $context->cart->updateQty(1, $productid, 0, $customization = $custom, $operator = 'down');
- return '';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement