$this->addJsLib('thiriet', 'js/libs/fluidbook/cart/fluidbook.cart.thiriet.js');
}
+ public function writeCFOCCart()
+ {
+
+ $this->lessVariables['import-cart-styles'] = 'cfoc';
+
+ $this->addJsLib('cfoc', 'js/libs/fluidbook/cart/fluidbook.cart.cfoc.js');
+
+ // NOTE: $this->config->basketReferences initially contains the uploaded filename and if we don't
+ // modify it, the writeCartConfig() function will replace it with the extracted data from the spreadsheet 🤐
+ // It would be much better if the extracted data had its own variable but it would break too many things to
+ // change it now, so we'll follow the same approach.
+
+ if (!empty($this->config->basketReferences)) {
+ if (file_exists($this->config->basketReferences) || CubeIT_Util_Url::isDistant($this->config->basketReferences)) {
+ $referencesFile = $this->config->basketReferences;
+ } else {
+ $referencesFile = $this->wdir . 'commerce/' . $this->config->basketReferences;
+ }
+ }
+
+ $references = [];
+
+ if (file_exists($referencesFile) || CubeIT_Util_Url::isDistant($referencesFile)) {
+ $raw_data = wsUtil::excelToArray($referencesFile);
+ $first_sheet_rows = reset($raw_data); // First sheet's data will be returned since it's the first array element
+
+ // Expected headings are: EXCLU, LIGNE, EAN, REF, DESIGNATION, COULEUR, QTE MINI, PRIX TTC
+ $column_headings = array_shift($first_sheet_rows); // We assume the first row will be the headings, so we slice it off
+ $column_headings = array_map(function ($heading) { // Clean the headings a bit
+ return trim(strtoupper($heading));
+ }, $column_headings);
+
+ foreach ($first_sheet_rows as $row) {
+
+ // First, trim values in case there are any stray spaces
+ $row = array_map('trim', $row);
+
+ // Next, set the headings as keys to make it easier to refer to the row values by name
+ $row = array_combine($column_headings, $row);
+
+ // For the 'EXCLU' field, this should be converted to a boolean
+ $row['EXCLU'] = ('exclu boutique' === $row['EXCLU']);
+
+ // The EAN and REF are required, so if they don't exist, we can assume it's not a valid row
+ if (empty($row['EAN']) || empty($row['REF'])) {
+ continue;
+ }
+
+ $references[$row['REF']][$row['EAN']] = $row;
+ }
+
+ }
+
+ $this->config->basketReferences = $references;
+
+ // It's possible to use the cartExtraSettings field in the parameters to define publication specific settings,
+ // such as the subject line used in the e-mail that is sent from the cart validation
+ $extra = wsHTML5Link::parseExtras($this->book->parametres->cartExtraSettings, true);
+
+ $this->config->cartEmailSubject = $extra['email_subject'] ?? 'Récapitulatif de votre commande CFOC';
+ }
+
public function writeCartConfig()
{
if ($this->book->parametres->cartLinkAppearance == 'overlay') {
$this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js');
$this->addJsLib('mopec', 'js/libs/fluidbook/cart/fluidbook.cart.mopec.js');
break;
+ case 'CFOC':
+ $this->writeCFOCCart();
+ break;
default:
break;
}
$dupData = $linkData;
$dupData['image'] = '';
$dupData['animation'] = '';
- $dupData['to'] = $linkData['image'];
+ $dupData['to'] = self::_SVGCleanAsset($linkData['image']);
if ($dupData['image_rollover'] != 'none' && !stristr($dupData['image_rollover'], '=')) {
$dupData['rollover'] = $dupData['image_rollover'];
}
}
}
+ protected function _SVGCleanAsset($a)
+ {
+ if (!stristr($a, '.svg')) {
+ return $a;
+ }
+ $clean = str_replace('.svg', '.o.svg', $a);
+ $path = $this->wdir . '/' . $a;
+ $opt = $this->wdir . '/' . $clean;
+
+ if (!file_exists($opt) || !filesize($opt) || filemtime($path) > filemtime($opt)) {
+ wsTools::_optimizeSVG($path, $opt);
+ }
+ return $clean;
+
+ }
+
public function supportSVG()
{
if (!$this->phonegap) {
return new webVideoLink($id, $init, $compiler);
case 11:
return new actionLink($id, $init, $compiler);
- case 12:
- if ($compiler->book->parametres->basketManager === 'Puma' || $compiler->book->parametres->basketManager === 'MIF' || $compiler->book->parametres->basketManager === 'Flexipan') {
- return new zoomProductLink($id, $init, $compiler);
- }
+ case 12: // Basket / Cart links
if ($compiler->book->parametres->product_zoom_references !== '') {
return new zoomProductLink($id, $init, $compiler);
}
switch ($compiler->book->parametres->basketManager) {
+ case 'CFOC':
+ return new CFOCCartLink($id, $init, $compiler);
case 'GrandVision':
return new grandVisionCartLink($id, $init, $compiler);
case 'GrandPavois':
case 'Remarkable':
return new remarkableCartLink($id, $init, $compiler);
case 'ZoomProductLink':
+ case 'Flexipan':
+ case 'Puma':
+ case 'MIF':
return new zoomProductLink($id, $init, $compiler);
default :
return new cartLink($id, $init, $compiler);
}
}
+class CFOCCartLink extends normalLink
+{
+ public function getUrl()
+ {
+ return '#/cart/add/' . $this->to;
+ }
+
+ // public function getAdditionnalContent()
+ // {
+ // return parent::getAdditionnalContent() . ' data-cfoc-ref="' . $this->to . '" ';
+ // }
+
+ public function getTooltip()
+ {
+ return 'Ajouter à ma sélection';
+ }
+}
+
class remarkableCartLink extends cartLink
{
class layerLink extends imageLink
{
- protected $maxzoom_default = 2;
+ protected $maxzoom_default = 1;
public $defaultZIndex = 31;
public function ignore()