From: Vincent Vanwaelscappel Date: Tue, 19 Dec 2023 19:05:54 +0000 (+0100) Subject: wip #6554 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=6db9206d84821562cfddae63ca0c5c351fd135e3;p=fluidbook-toolbox.git wip #6554 @2 --- diff --git a/app/Fluidbook/Compiler/Cart.php b/app/Fluidbook/Compiler/Cart.php index 6ebd0f7c9..722bfd866 100644 --- a/app/Fluidbook/Compiler/Cart.php +++ b/app/Fluidbook/Compiler/Cart.php @@ -260,16 +260,32 @@ trait Cart } + public function writePumaSECart() + { + + $this->lessVariables['import-cart-styles'] = 'puma-se'; + $this->addJsLib('puma-se', 'js/libs/fluidbook/cart/fluidbook.cart.puma-se.js'); + + $this->_commonPuma(); + + } + + /** * @throws \Exception */ public function writePumaCart() { $this->lessVariables['import-cart-styles'] = 'puma'; + $this->addJsLib('puma', 'js/libs/fluidbook/cart/fluidbook.cart.puma.js'); + $this->_commonPuma(); + } + + protected function _commonPuma() + { $this->addJsLib('parsley', 'js/libs/parsley.min.js'); $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); - $this->addJsLib('puma', 'js/libs/fluidbook/cart/fluidbook.cart.puma.js'); $this->addJsLib('html2pdf', 'js/libs/html2pdf/html2pdf.min.js'); $this->addJsLib('exceljs', 'js/libs/exceljs.min.js'); $this->addVideoJs(); @@ -324,6 +340,50 @@ trait Cart } $this->log('Puma product zoom done'); + + $aliases = []; + if (file_exists($this->wdir . 'commerce/aliases.txt')) { + $lines = explode("\n", file_get_contents($this->wdir . 'commerce/aliases.txt')); + foreach ($lines as $line) { + $bases = []; + $refs = explode('/', trim($line)); + foreach ($cartReferences as $ref => $d) { + if (str_starts_with($ref, $refs[0])) { + $bases[] = $ref; + } + } + if (!count($bases)) { + continue; + } + + for ($i = 1; $i < count($refs); $i++) { + foreach ($cartReferences as $ref => $d) { + if (!str_starts_with($ref, $refs[$i])) { + continue; + } + $foundColor = false; + foreach ($bases as $base) { + if (substr($ref, -2) === substr($base, -2)) { + $aliases[$ref] = $base; + $foundColor = true; + break; + } + } + if (!$foundColor) { + $aliases[$ref] = $bases[0]; + } + } + } + } + } + + foreach ($aliases as $alias => $base) { + $cartReferences[$alias]['zoom_image'] = $cartReferences[$base]['zoom_image']; + $cartReferences[$alias]['zoom_image_ratio'] = $cartReferences[$base]['zoom_image_ratio']; + } + + $this->log('Puma aliases handled'); + $this->config->setRaw('product_zoom_references', $productZoomReferences); $this->config->setRaw('basketReferences', $cartReferences); @@ -472,6 +532,7 @@ trait Cart } } + public function writeCartConfig() { if ($this->fluidbookSettings->cartLinkAppearance == 'overlay') { @@ -490,6 +551,9 @@ trait Cart case 'Puma': $this->writePumaCart(); return; + case 'Puma-SE': + $this->writePumaSECart(); + return; case 'MIF': $this->writeMIFCart(); return; diff --git a/app/Fluidbook/Link/Cart/PumaCartLink.php b/app/Fluidbook/Link/Cart/PumaCartLink.php index f5277c3a3..48e27a8f9 100644 --- a/app/Fluidbook/Link/Cart/PumaCartLink.php +++ b/app/Fluidbook/Link/Cart/PumaCartLink.php @@ -4,7 +4,7 @@ namespace App\Fluidbook\Link\Cart; use Fluidbook\Tools\Links\CartLink; -class PumaCartLink extends cartLink +class PumaCartLink extends CartLink { public function getInnerContent() { @@ -30,10 +30,14 @@ class PumaCartLink extends cartLink '; } + public function getAdditionnalContent() { + $removeTooltip = $this->to === 'auto:all_in_page' ? 'remove all page products from cart' : 'remove from cart'; + $res = parent::getAdditionnalContent(); - $res .= ' data-tooltip-conditional="' . htmlspecialchars(json_encode(['.active' => 'remove from cart'])) . '" '; + $res .= ' data-tooltip-conditional="' . htmlspecialchars(json_encode(['.active' => $removeTooltip])) . '" '; + return $res; } }