Advertisement
Guest User

Untitled

a guest
May 21st, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.06 KB | None | 0 0
  1. public static function procat($productid)
  2. {
  3. //Config area//
  4. //Here we will set the values used throughout the function.
  5. $Cat1 = '29';
  6. $Cat2 = '30';
  7. $Cat3 = '28';
  8. $Cat4 = '31';
  9. $Cat5 = '33';
  10.  
  11. //NIEUWCATTOE
  12. //End of config
  13. $nocat1 = '0';
  14. $nocat2 = '0';
  15. $nocat3 = '0';
  16. $nocat4 = '0';
  17. $nocat5 = '0';
  18. //End of setting values
  19. $resultcheckcat1 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat1);
  20. $resultcheckcat2 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat2);
  21. $resultcheckcat3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat3);
  22. $resultcheckcat4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat4);
  23. $resultcheckcat5 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat5);
  24. //Check voor item 1
  25. if($resultcheckcat1 == '1')
  26. {
  27. $element = "item1-" . $productid;
  28. //Hier maakt hij een element zichtbaar\\
  29. echo "<script type='text/javascript'>document.getElementById('$element').style.display = 'block';</script>";
  30.  
  31. CartControllerCore::cart($productid, '29');
  32. }
  33. elseif ($resultcheckcat1 == '0') {
  34. $nocat1 = '1';
  35. }
  36. elseif ($resultcheckcat1 >= '2') {
  37. $ERROR = "true";
  38. }
  39.  
  40.  
  41. //Check voor item 2
  42. if($resultcheckcat2 == '1')
  43. {
  44. $element2 = "item2-" . $productid;
  45. echo "<script type='text/javascript'>document.getElementById('$element2').style.display = 'block';</script>";
  46.  
  47. CartControllerCore::cart($productid, '30');
  48. }
  49. elseif ($resultcheckcat2 == '0') {
  50. $nocat2 = '1';
  51. }
  52. elseif ($resultcheckcat2 >= '2') {
  53. $ERROR = "true";
  54. }
  55.  
  56.  
  57. //Check voor item 3
  58. if($resultcheckcat3 == '1')
  59. {
  60. $element3 = "item3-" . $productid;
  61. echo "<script type='text/javascript'>document.getElementById('$element3').style.display = 'block';</script>";
  62.  
  63. CartControllerCore::cart($productid, '28');
  64. }
  65. if($resultcheckcat3 == '0') {
  66. $nocat3 = '1';
  67. }
  68. elseif ($resultcheckcat3 >= '2') {
  69. $ERROR = "true";
  70. }
  71.  
  72. //Check voor item 4
  73. if($resultcheckcat4 == '1')
  74. {
  75. $element4 = "item4-" . $productid;
  76. echo "<script type='text/javascript'>document.getElementById('$element4').style.display = 'block';</script>";
  77.  
  78. CartControllerCore::cart($productid, '31');
  79. }
  80. if($resultcheckcat4 == '0') {
  81. $nocat4 = '1';
  82. }
  83. elseif ($resultcheckcat4 >= '2') {
  84. $ERROR = "true";
  85. }
  86.  
  87. //Check voor item 5
  88. if($resultcheckcat5 == '1')
  89. {
  90. $element5 = "item5-" . $productid;
  91. echo "<script type='text/javascript'>document.getElementById('$element5').style.display = 'block';</script>";
  92.  
  93. CartControllerCore::cart($productid, '33'); // Let op dat je de goede pakt. Check in backend nogmaals voor productid om zeker te zijn
  94. }
  95. if($resultcheckcat5 == '0') {
  96. $nocat5 = '1';
  97. }
  98. elseif ($resultcheckcat5 >= '2') {
  99. $ERROR = "true";
  100. }
  101.  
  102.  
  103. //FUNCTIEPROCAT
  104.  
  105. if($nocat3 == '1' && $nocat2 == '1' && $nocat1 == '0' && $nocat4 == '0'){
  106. $elementnocat = "cart-item-" . $productid;
  107. echo "<script type='text/javascript'>document.getElementById('$elementnocat').style.display = 'none';</script>";
  108. }
  109.  
  110. return '';
  111. }
  112.  
  113. public static function clean($productid, $cat, $cart)
  114. {
  115. $resultcheckcat = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$cat);
  116. if ($resultcheckcat == '1')
  117. {
  118. $option = 1;
  119. $data = array(
  120. 'cart_id' => $cart,
  121. 'product_id' => $productid,
  122. 'option_id' => $option,
  123. 'cat_id' => $cat,
  124. );
  125. Db::getInstance()->insert('attribute_cart_print', $data);
  126. $context = Context::getContext();
  127. $cart = $context->cart;
  128. if($cat == '30'){
  129. $cart->updateQty(1, 23);
  130. }elseif ($cat == '29') {
  131. $cart->updateQty(1, 22);
  132. }elseif ($cat == '28') {
  133. $cart->updateQty(1, 24);
  134. }elseif ($cat == '31') {
  135. $cart->updateQty(1, 27);
  136. }
  137. if ($cat == '33') {
  138. $cart->updateQty(1, 27);
  139. }
  140.  
  141.  
  142. //CLEANFUNCTION
  143. echo "<script>location.reload();</script> ";
  144. }
  145. return '';
  146. }
  147.  
  148. public static function check($productid, $Cat)
  149. {
  150. $resultcheckcat = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat);
  151. if ($resultcheckcat == '1') {
  152. return '1';
  153. }
  154. else {
  155. return '0';
  156. }
  157. }
  158.  
  159. public static function getprijs($cat)
  160. {
  161. $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$cat);
  162. $prijs = $row['price'];
  163. $prijs = $prijs / 100 * 121;
  164. return (float)$prijs;
  165. }
  166.  
  167. public static function testfunctie1($productid)
  168. {
  169.  
  170. //$context = Context::getContext();
  171. //$cartid = $context->cart->id;
  172. //$Cat3 = '28';
  173. //Deze functie wordt gebruikt om te testen. :)
  174. //$result = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'attribute_cart_print` WHERE cat_id = '.$Cat3.' AND cart_id = '.$cartid.' AND product_id = '.$product);
  175. return '';
  176. }
  177.  
  178. public static function delete($productid)
  179. {
  180. //Config area//
  181. //Here we will set the values used throughout the function.
  182. $Cat1 = '29';
  183. $Cat2 = '30';
  184. $Cat3 = '28';
  185. $Cat4 = '31';
  186. $Cat5 = '33';
  187. //variable1
  188. //End of config
  189. $foto = '22';
  190. $voor = '23';
  191. $service = '24';
  192. $zwart = '26';
  193. $kleur = '27';
  194. //variable2
  195. //End of setting values
  196. $resultcheckcat1 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat1);
  197. $resultcheckcat2 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat2);
  198. $resultcheckcat3 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat3);
  199. $resultcheckcat4 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat4);
  200. $resultcheckcat5 = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$productid.' AND `id_category` = '.$Cat5);
  201.  
  202. //sqldelete
  203. //Check voor item 3
  204. $context = Context::getContext();
  205. $cart_products = $context->cart->getProducts();
  206. foreach ($cart_products as $cart_product)
  207. {
  208. if($cart_product['id_product'] == $service)
  209. {
  210. if($resultcheckcat3 == '1')
  211. {
  212. $cartid = $context->cart->id;
  213. $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);
  214.  
  215. if($result3 == '1')
  216. {
  217. $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat3.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
  218. $id = $row['id'];
  219. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  220.  
  221. $quantity = $cart_product['cart_quantity'];
  222. $newquantity = $quantity - 1;
  223. $cart = $context->cart;
  224. $cart->updateQty(0, $service);
  225. $cart->updateQty($newquantity, $service);
  226. }
  227. }
  228. }
  229. if($cart_product['id_product'] == $voor)
  230. {
  231. if($resultcheckcat2 == '1')
  232. {
  233. $cartid = $context->cart->id;
  234. $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);
  235.  
  236. if($result2 == '1')
  237. {
  238. $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat2.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
  239. $id = $row['id'];
  240. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  241.  
  242. $quantity = $cart_product['cart_quantity'];
  243. $newquantity = $quantity - 1;
  244. $cart = $context->cart;
  245. $cart->updateQty(0, $voor);
  246. $cart->updateQty($newquantity, $voor);
  247. }
  248. }
  249. }
  250. if($cart_product['id_product'] == $foto)
  251. {
  252. if($resultcheckcat1 == '1')
  253. {
  254. $cartid = $context->cart->id;
  255. $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);
  256.  
  257. if($result1 == '1')
  258. {
  259. $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat1.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
  260. $id = $row['id'];
  261. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  262.  
  263. $quantity = $cart_product['cart_quantity'];
  264. $newquantity = $quantity - 1;
  265. $cart = $context->cart;
  266. $cart->updateQty(0, $foto);
  267. $cart->updateQty($newquantity, $foto);
  268. }
  269. }
  270. }
  271.  
  272. //tbd
  273. if($cart_product['id_product'] == $zwart)
  274. {
  275. if($resultcheckcat4 == '1')
  276. {
  277. $cartid = $context->cart->id;
  278. $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);
  279.  
  280. if($result4 == '1')
  281. {
  282. $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);
  283. $id = $row['id'];
  284. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  285.  
  286. $quantity = $cart_product['cart_quantity'];
  287. $newquantity = $quantity - 1;
  288. $cart = $context->cart;
  289. $cart->updateQty(0, $foto);
  290. $cart->updateQty($newquantity, $zwart);
  291. }
  292. }
  293. }
  294.  
  295. //tbd
  296. if($cart_product['id_product'] == $kleur)
  297. {
  298. if($resultcheckcat4 == '1')
  299. {
  300. $cartid = $context->cart->id;
  301. $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);
  302.  
  303. if($result5 == '1')
  304. {
  305. $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat4.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
  306. $id = $row['id'];
  307. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  308.  
  309. $quantity = $cart_product['cart_quantity'];
  310. $newquantity = $quantity - 1;
  311. $cart = $context->cart;
  312. $cart->updateQty(0, $kleur);
  313. $cart->updateQty($newquantity, $kleur);
  314. }
  315. }
  316. }
  317.  
  318. if($cart_product['id_product'] == $kleur)
  319. {
  320. if($resultcheckcat5 == '1')
  321. {
  322. $cartid = $context->cart->id;
  323. $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);
  324.  
  325. if($result6 == '1')
  326. {
  327. $row = Db::getInstance()->getRow('SELECT * FROM `ps_attribute_cart_print` WHERE cat_id = '.$Cat5.' AND cart_id = '.$cartid.' AND product_id = '.$productid);
  328. $id = $row['id'];
  329. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  330.  
  331. $quantity = $cart_product['cart_quantity'];
  332. $newquantity = $quantity - 1;
  333. $cart = $context->cart;
  334. $cart->updateQty(0, $kleur);
  335. $cart->updateQty($newquantity, $kleur);
  336. }
  337. }
  338. }
  339.  
  340.  
  341. //FUNCTIONDELETE
  342. }
  343. //Ivm met designer moet dit gebeuren
  344. $cart->updateQty(0, $productid);
  345. // here we need to make a check which deletes all remaining option 2's with product.id / cart->id
  346. $context = Context::getContext();
  347. $cartid = $context->cart->id;
  348. $result = Db::getInstance()->executeS('SELECT * FROM ps_attribute_cart_print WHERE cart_id = '.$cartid.' AND product_id = '.$productid.' AND option_id = 2 ');
  349. foreach($result as $row)
  350. {
  351. $id = $row['id'];
  352. Db::getInstance()->delete('ps_attribute_cart_print', 'id = '.$id.'', 1);
  353. }
  354. echo "<script>location.reload();</script> ";
  355. }
  356.  
  357. public static function onclick($click)
  358. {
  359. if($click == 'optie1')
  360. {
  361. $productid = Tools::getValue('optie1');
  362. $context = Context::getContext();
  363. $cartid = $context->cart->id;
  364. $cat = '29';
  365. $pro = '22';
  366.  
  367. $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);
  368.  
  369. if($resultoptie1 == '1')
  370. {
  371. $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 ';
  372. Db::getInstance()->execute($sql);
  373. $cart = $context->cart;
  374. $cart->updateQty(1, $pro);
  375. }
  376. }
  377.  
  378. if($click == 'optie2')
  379. {
  380. $productid = Tools::getValue('optie2');
  381. $context = Context::getContext();
  382. $cartid = $context->cart->id;
  383. $cat = '29';
  384. $pro = '22';
  385.  
  386. $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);
  387.  
  388. if($resultoptie2 == '1')
  389. {
  390. $cart_products = $context->cart->getProducts();
  391. $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 ';
  392. Db::getInstance()->execute($sql);
  393. foreach ($cart_products as $cart_product)
  394. {
  395. if($cart_product['id_product'] == $pro)
  396. {
  397. $quantity = $cart_product['cart_quantity'];
  398. $newquantity = $quantity - 1;
  399. $cart = $context->cart;
  400. if($newquantity == '0')
  401. {
  402. $cart->updateQty(0, $pro);
  403. }
  404. else
  405. {
  406. $cart->updateQty(0, $pro);
  407. $cart->updateQty($newquantity, $pro);
  408. }
  409. }
  410. }
  411. }
  412. }
  413.  
  414. if($click == 'optie3')
  415. {
  416. $productid = Tools::getValue('optie3');
  417. $context = Context::getContext();
  418. $cartid = $context->cart->id;
  419. $cat = '30';
  420. $pro = '23';
  421.  
  422. $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);
  423.  
  424. if($resultoptie3 == '1')
  425. {
  426. $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 ';
  427. Db::getInstance()->execute($sql);
  428. $cart = $context->cart;
  429. $cart->updateQty(1, $pro);
  430. }
  431. }
  432.  
  433. if($click == 'optie4')
  434. {
  435. $productid = Tools::getValue('optie4');
  436. $context = Context::getContext();
  437. $cartid = $context->cart->id;
  438. $cat = '30';
  439. $pro = '23';
  440.  
  441. $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);
  442.  
  443. if($resultoptie4 == '1')
  444. {
  445. $cart_products = $context->cart->getProducts();
  446. $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 ';
  447. Db::getInstance()->execute($sql);
  448. foreach ($cart_products as $cart_product)
  449. {
  450. if($cart_product['id_product'] == $pro)
  451. {
  452. $quantity = $cart_product['cart_quantity'];
  453. $newquantity = $quantity - 1;
  454. $cart = $context->cart;
  455. if($newquantity == '0')
  456. {
  457. $cart->updateQty(0, $pro);
  458. }
  459. else
  460. {
  461. $cart->updateQty(0, $pro);
  462. $cart->updateQty($newquantity, $pro);
  463. }
  464. }
  465. }
  466. }
  467. }
  468.  
  469. if($click == 'optie5')
  470. {
  471. $productid = Tools::getValue('optie5');
  472. $context = Context::getContext();
  473. $cartid = $context->cart->id;
  474. $cat = '28';
  475. $pro = '24';
  476.  
  477. $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);
  478.  
  479. if($resultoptie3 == '1')
  480. {
  481. $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 ';
  482. Db::getInstance()->execute($sql);
  483. $cart = $context->cart;
  484. $cart->updateQty(1, $pro);
  485. }
  486. }
  487.  
  488. if($click == 'optie6')
  489. {
  490. $productid = Tools::getValue('optie6');
  491. $context = Context::getContext();
  492. $cartid = $context->cart->id;
  493. $cat = '28';
  494. $pro = '24';
  495.  
  496. $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);
  497.  
  498. if($resultoptie4 == '1')
  499. {
  500. $cart_products = $context->cart->getProducts();
  501. $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 ';
  502. Db::getInstance()->execute($sql);
  503. foreach ($cart_products as $cart_product)
  504. {
  505. if($cart_product['id_product'] == $pro)
  506. {
  507. $quantity = $cart_product['cart_quantity'];
  508. $newquantity = $quantity - 1;
  509. $cart = $context->cart;
  510. if($newquantity == '0')
  511. {
  512. $cart->updateQty(0, $pro);
  513. }
  514. else
  515. {
  516. $cart->updateQty(0, $pro);
  517. $cart->updateQty($newquantity, $pro);
  518. }
  519. }
  520. }
  521. }
  522. }
  523.  
  524. if($click == 'optie7')
  525. {
  526. $productid = Tools::getValue('optie7');
  527. $context = Context::getContext();
  528. $cartid = $context->cart->id;
  529. $cat = '31';
  530. $pro1 = '27';
  531. $pro2 = '26';
  532.  
  533. $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);
  534.  
  535. if($resultoptie3 == '1')
  536. {
  537. $cart_products = $context->cart->getProducts();
  538. $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 ';
  539. Db::getInstance()->execute($sql);
  540. foreach ($cart_products as $cart_product)
  541. {
  542. if($cart_product['id_product'] == $pro2)
  543. {
  544. $quantity = $cart_product['cart_quantity'];
  545. $newquantity = $quantity - 1;
  546. $cart = $context->cart;
  547. if($newquantity == '0')
  548. {
  549. $cart->updateQty(0, $pro2);
  550. }
  551. else
  552. {
  553. $cart->updateQty(0, $pro2);
  554. $cart->updateQty($newquantity, $pro2);
  555. }
  556. }
  557. }
  558. $cart = $context->cart;
  559. $cart->updateQty(1, $pro1);
  560. }
  561. }
  562.  
  563. if($click == 'optie8')
  564. {
  565. $productid = Tools::getValue('optie8');
  566. $context = Context::getContext();
  567. $cartid = $context->cart->id;
  568. $cat = '31';
  569. $pro1 = '27';
  570. $pro2 = '26';
  571.  
  572. $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);
  573.  
  574. if($resultoptie4 == '1')
  575. {
  576. $cart_products = $context->cart->getProducts();
  577. $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 ';
  578. Db::getInstance()->execute($sql);
  579. foreach ($cart_products as $cart_product)
  580. {
  581. if($cart_product['id_product'] == $pro1)
  582. {
  583. $quantity = $cart_product['cart_quantity'];
  584. $newquantity = $quantity - 1;
  585. $cart = $context->cart;
  586. if($newquantity == '0')
  587. {
  588. $cart->updateQty(0, $pro1);
  589. }
  590. else
  591. {
  592. $cart->updateQty(0, $pro1);
  593. $cart->updateQty($newquantity, $pro1);
  594. }
  595. }
  596. }
  597. $cart = $context->cart;
  598. $cart->updateQty(1, $pro2);
  599. }
  600. }
  601.  
  602.  
  603. //ONCLICK22
  604. return '';
  605. }
  606.  
  607. public static function detailedtotal()
  608. {
  609. $context = Context::getContext();
  610. $cart_products = $context->cart->getProducts();
  611.  
  612. foreach ($cart_products as $cart_product)
  613. {
  614. $foto = '22';
  615. $voor = '23';
  616. $service = '24';
  617. $zwart = '26';
  618. $kleur = '27';
  619.  
  620. //variable totals
  621. if($cart_product['id_product'] == $foto)
  622. {
  623. $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$foto);
  624. $prijs = $row['price'];
  625. $quantity = $cart_product['cart_quantity'];
  626. $prijs = $prijs / 100 * 121;
  627. $prijs = Tools::ps_round($prijs,2);
  628. echo "<div class='cart-summary-line'>
  629. <span class='label'>";
  630. echo $quantity;
  631. echo " x Drukken foto";
  632. echo "</span>";
  633. echo "<span class='value'>";
  634. echo $quantity;
  635. echo "x € ";
  636. echo (float)$prijs;
  637. echo "<script>
  638. document.write(parseFloat($prijs).toFixed(2));
  639. </script>";
  640. echo "</span>
  641. </div>";
  642. }
  643. if($cart_product['id_product'] == $voor)
  644. {
  645. $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$voor);
  646. $prijs = $row['price'];
  647. $quantity = $cart_product['cart_quantity'];
  648. $prijs = $prijs / 100 * 121;
  649. $prijs = Tools::ps_round($prijs,2);
  650. echo "<div class='cart-summary-line'>
  651. <span class='label'>";
  652. echo $quantity;
  653. echo " x Drukken voorkant";
  654. echo "</span>";
  655. echo "<span class='value'>";
  656. echo $quantity;
  657. echo "x € ";
  658. echo (float)$prijs;
  659. echo "</span>
  660. </div>";
  661. }
  662. if($cart_product['id_product'] == $service)
  663. {
  664. $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$service);
  665. $prijs = $row['price'];
  666. $quantity = $cart_product['cart_quantity'];
  667. $prijs = $prijs / 100 * 121;
  668. $prijs = Tools::ps_round($prijs,2);
  669. echo "<div class='cart-summary-line'>
  670. <span class='label'>";
  671. echo $quantity;
  672. echo " x In elkaar zet service:";
  673. echo "</span>";
  674. echo "<span class='value'>";
  675. echo $quantity;
  676. echo "x € ";
  677. echo (float)$prijs;
  678. echo "</span>
  679. </div>";
  680. }
  681. if($cart_product['id_product'] == $zwart)
  682. {
  683. $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$zwart);
  684. $prijs = $row['price'];
  685. $quantity = $cart_product['cart_quantity'];
  686. $prijs = $prijs / 100 * 121;
  687. $prijs = Tools::ps_round($prijs,2);
  688. echo "<div class='cart-summary-line'>
  689. <span class='label'>";
  690. echo $quantity;
  691. echo " x Drukken zwart:";
  692. echo "</span>";
  693. echo "<span class='value'>";
  694. echo $quantity;
  695. echo "x € ";
  696. echo (float)$prijs;
  697. echo "</span>
  698. </div>";
  699. }
  700. if($cart_product['id_product'] == $kleur)
  701. {
  702. $row = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$kleur);
  703. $prijs = $row['price'];
  704. $quantity = $cart_product['cart_quantity'];
  705. (float)$prijs = $prijs / 100 * 121;
  706. $prijs = Tools::ps_round($prijs,2);
  707. echo "<div class='cart-summary-line'>
  708. <span class='label'>";
  709. echo $quantity;
  710. echo " x Drukken kleur:";
  711. echo "</span>";
  712. echo "<span class='value'>";
  713. echo $quantity;
  714. echo "x € ";
  715. echo (float)$prijs;
  716. echo "</span>
  717. </div>";
  718. }
  719.  
  720. //PLAKHIERBOVEN
  721. }
  722. return '';
  723. }
  724.  
  725. public static function cart($productid, $cat)
  726. {
  727. $context = Context::getContext();
  728. $cart = $context->cart->id;
  729.  
  730. $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);
  731. if($result == '1')
  732. {
  733.  
  734. }else {
  735. CartControllerCore::clean($productid, $cat, $cart);
  736. }
  737. return '';
  738. }
  739.  
  740. public static function opstart($productid)
  741. {
  742. $context = Context::getContext();
  743. $cartid = $context->cart->id;
  744.  
  745. $Cat1 = '29';
  746. $Cat2 = '30';
  747. $Cat3 = '28';
  748. $Cat4 = '31';
  749. $Cat5 = '33';
  750.  
  751. //OPSTART1
  752.  
  753. $result = Db::getInstance()->executeS('SELECT * FROM ps_attribute_cart_print WHERE cart_id = '.$cartid.' AND product_id = '.$productid);
  754. foreach($result as $row)
  755. {
  756. $id = $row['option_id'];
  757. $cat = $row['cat_id'];
  758. if($cat == '28')
  759. {
  760. if($id == '1')
  761. {
  762. echo "<script>
  763. var element = document.getElementById('optie5-".$productid."');
  764. element.classList.remove('btnselect');
  765. element.classList.add('btnselects');
  766. </script>";
  767. }
  768. elseif ($id == '2')
  769. {
  770. echo "<script>
  771. var element = document.getElementById('optie6-".$productid."');
  772. element.classList.remove('btnselect');
  773. element.classList.add('btnselects');
  774. </script>";
  775. }
  776. }
  777. if($cat == '29')
  778. {
  779. if($id == '1')
  780. {
  781. echo "<script>
  782. var element = document.getElementById('optie1-".$productid."');
  783. element.classList.remove('btnselect');
  784. element.classList.add('btnselects');
  785. </script>";
  786. }
  787. elseif ($id == '2')
  788. {
  789. echo "<script>
  790. var element = document.getElementById('optie2-".$productid."');
  791. element.classList.remove('btnselect');
  792. element.classList.add('btnselects');
  793. </script>";
  794. }
  795. }
  796. if($cat == '30')
  797. {
  798. if($id == '1')
  799. {
  800. echo "<script>
  801. var element = document.getElementById('optie3-".$productid."');
  802. element.classList.remove('btnselect');
  803. element.classList.add('btnselects');
  804. </script>";
  805. }
  806. elseif ($id == '2')
  807. {
  808. echo "<script>
  809. var element = document.getElementById('optie4-".$productid."');
  810. element.classList.remove('btnselect');
  811. element.classList.add('btnselects');
  812. </script>";
  813. }
  814. }
  815. if($cat == '31')
  816. {
  817. if($id == '1')
  818. {
  819. echo "<script>
  820. var element = document.getElementById('optie7-".$productid."');
  821. element.classList.remove('btnselect');
  822. element.classList.add('btnselects');
  823. </script>";
  824. }
  825. elseif ($id == '2')
  826. {
  827. echo "<script>
  828. var element = document.getElementById('optie8-".$productid."');
  829. element.classList.remove('btnselect');
  830. element.classList.add('btnselects');
  831. </script>";
  832. }
  833. }
  834. if($cat == '33')
  835. {
  836. if($id == '1')
  837. {
  838. echo "<script>
  839. var element = document.getElementById('optie9-".$productid."');
  840. element.classList.remove('btnselect');
  841. element.classList.add('btnselects');
  842. </script>";
  843. }
  844. }
  845.  
  846. //OPSTART2
  847. }
  848.  
  849. return '';
  850. }
  851.  
  852. public static function leegcheck()
  853. {
  854. $context = Context::getContext();
  855. $cart_products = $context->cart->getProducts();
  856.  
  857. $count = 0;
  858. foreach ($cart_products as $cart_product)
  859. {
  860. 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)
  861. {
  862. $count + 1;
  863. }
  864. }
  865. if($count == 0)
  866. {
  867. $context->cart->delete();
  868. }
  869. return '';
  870. }
  871.  
  872. public static function service()
  873. {
  874. $context = Context::getContext();
  875.  
  876. $cart_products = $context->cart->getProducts();
  877.  
  878. $context->cart->updateQty(0, 24);
  879.  
  880. foreach ($cart_products as $cart_product)
  881. {
  882. $productid = $cart_product['id_product'];
  883. $categorie = '28';
  884. $cart = $context->cart->id;
  885. 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)
  886. {
  887. $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);
  888. if($result == '1')
  889. {
  890. $quantity = $cart_product['cart_quantity'];
  891. $context->cart->updateQty($quantity, 24);
  892.  
  893. $sql = 'UPDATE ' . _DB_PREFIX_ . 'attribute_cart_print SET ammount = '.$quantity.' WHERE cart_id = '.$cart.' AND product_id = '.$productid.' AND cat_id = '.$categorie.'';
  894. Db::getInstance()->execute($sql);
  895. }
  896. }
  897. }
  898. return '';
  899. }
  900.  
  901. public static function up($productid)
  902. {
  903. $context = Context::getContext();
  904. $cart_products = $context->cart->getProducts();
  905.  
  906. $cart_products = $context->cart->getProducts();
  907. foreach ($cart_products as $cart_product)
  908. {
  909. if($cart_product['id_product'] == $productid)
  910. {
  911. $custom = $cart_product['id_customization'];
  912. }
  913. }
  914. $context->cart->updateQty(1, $productid, 0, $customization = $custom, $operator = 'up');
  915.  
  916. return '';
  917. }
  918.  
  919. public static function down($productid)
  920. {
  921. $context = Context::getContext();
  922. $cart_products = $context->cart->getProducts();
  923.  
  924. $cart_products = $context->cart->getProducts();
  925. foreach ($cart_products as $cart_product)
  926. {
  927. if($cart_product['id_product'] == $productid)
  928. {
  929. $custom = $cart_product['id_customization'];
  930. }
  931. }
  932. $context->cart->updateQty(1, $productid, 0, $customization = $custom, $operator = 'down');
  933. return '';
  934. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement