diff --git a/templates/frontOffice/default/assets/css/styles.css b/templates/frontOffice/default/assets/css/styles.css index 941261a00..7dc795170 100644 --- a/templates/frontOffice/default/assets/css/styles.css +++ b/templates/frontOffice/default/assets/css/styles.css @@ -5174,7 +5174,7 @@ body.modal-open, left: 100%; } .carousel-inner > .prev { - left: -100%; + left: -99.99999999%; } .carousel-inner > .next.left, .carousel-inner > .prev.right { @@ -10939,7 +10939,7 @@ td.products-grid .item .product-info .description { display: block; } .availability .in-stock { - color: #44B661; + color: #5cb85c; font-style: italic; font-weight: bold; text-transform: uppercase; @@ -10954,7 +10954,7 @@ td.products-grid .item .product-info .description { font-style: italic; } .availability .out-of-stock { - color: #FF0000; + color: #f0ad4e; font-style: italic; font-weight: bold; text-transform: uppercase; @@ -12608,7 +12608,6 @@ td.product .name > a:focus, #product-details .product-info .pse-name { color: #555555; font-size: 14px; - margin-left: 10px; } #product-details .product-price .price-container { margin-left: -15px; diff --git a/templates/frontOffice/default/assets/js/script.js b/templates/frontOffice/default/assets/js/script.js index bdcc588ef..2ac548ccf 100644 --- a/templates/frontOffice/default/assets/js/script.js +++ b/templates/frontOffice/default/assets/js/script.js @@ -21,6 +21,220 @@ } }()); + +var pseManager = (function($){ + + // cache dom elements + var manager = {}; + var $pse = {}; + + function init(){ + $pse = { + "id": $("#pse-id"), + "product": $("#product"), + "name": $("#pse-name"), + "ref": $("#pse-ref"), + "ean": $("#pse-ean"), + "availability": $("#pse-availability"), + "quantity": $("#quantity"), + "promo": $("#pse-promo"), + "new": $("#pse-new"), + "weight": $("#pse-weight"), + "price": $("#pse-price"), + "priceOld": $("#pse-price-old"), + "submit": $("#pse-submit"), + "options": {}, + "pseId": null + }; + } + + function buildProductForm() { + var pse = null, + combinationId = null, + combinationValue = null, + combinationValueId = null; + + // get the select for options + $("#pse-options .pse-option").each(function(){ + var $option = $(this); + $pse['options'][$option.data("attribute")] = $option; + $option.on("change", updateProductForm); + }); + + // build select + for (combinationValueId in PSE_COMBINATIONS_VALUE) { + combinationValue = PSE_COMBINATIONS_VALUE[combinationValueId]; + $pse.options[combinationValue[1]] + .append(""); + } + + // initialization for the first default pse + $pse.pseId = $pse.id.val(); + if (PSE_COUNT > 1) { + setPseForm(); + } + } + + function setPseForm(id) { + var i = 0, + pse = null, + combinationValueId; + pse = PSE[id || $pse.pseId]; + for (var i=0; i 1) { + + // get form data + selection = getFormSelection(); + // get the pse + pseId = pseExist(selection); + + if ( ! pseId ) { + // not exists, revert + setPseForm(); + } else { + $pse.pseId = pseId; + } + } + + // Update UI + updateProductUI(); + } + + function updateProductUI() { + var pse = PSE[$pse.pseId], + name = [], + pseValueId, + i + ; + + $pse.ref.html(pse.ref); + // $pse.ean.html(pse.ean); + // name + if (PSE_COUNT > 1) { + for (i = 0; i < pse.combinations.length; i++){ + pseValueId = pse.combinations[i] + name.push( + //PSE_COMBINATIONS[PSE_COMBINATIONS_VALUE[pseValueId][1]].name + + //":" + + PSE_COMBINATIONS_VALUE[pseValueId][0] + ) + } + $pse.name.html(" - " + name.join(", ") + ""); + } + + // promo + if (pse.isPromo) { + $pse.product.addClass("product--is-promo"); + } else { + $pse.product.removeClass("product--is-promo"); + } + + // new + if (pse.isNew) { + $pse.product.addClass("product--is-new"); + } else { + $pse.product.removeClass("product--is-new"); + } + + // availability + if (pse.quantity > 0 || ! PSE_CHECK_AVAILABILITY) { + $pse.availability + .removeClass("out-of-stock") + .addClass("in-stock") + .attr("href", "http://schema.org/InStock"); + + if (parseInt($pse.quantity.val()) > pse.quantity){ + $pse.quantity.val(pse.quantity); + } + + if (PSE_CHECK_AVAILABILITY) { + $pse.quantity.attr("max", pse.quantity); + } else { + $pse.quantity.attr("max", PSE_DEFAULT_AVAILABLE_STOCK); + } + $pse.submit.prop("disabled", false); + + } else { + $pse.availability.removeClass("in-stock") + .addClass("out-of-stock") + .attr("href", "http://schema.org/OutOfStock"); + + $pse.submit.prop("disabled", true); + } + + // price + if (pse.isPromo){ + $pse.priceOld.html(pse.price); + $pse.price.html(pse.promo); + } else { + $pse.priceOld.html(""); + $pse.price.html(pse.price); + } + } + + function pseExist(selection) { + var pseId, + pse = null, + combinations, + i, + j, + existCombination; + + for (pse in PSE){ + pseId = pse; + combinations = PSE[pse].combinations; + for (i = 0; i < selection.length; i++){ + existCombination = false; + for (j = 0; j < combinations.length; j++){ + if (selection[i] == combinations[j]){ + existCombination = true; + break; + } + } + if (existCombination === false) { + break; + } + } + if (existCombination) { + return pseId; + } + } + + return false; + } + + function getFormSelection() { + var selection = [], + combinationId; + + for (combinationId in $pse.options){ + selection.push($pse.options[combinationId].val()); + } + + return selection; + } + + manager.load = function(){ + init(); + buildProductForm(); + updateProductForm(); + } + + return manager; + +}(jQuery)); + + /* JQUERY PREVENT CONFLICT */ (function ($) { @@ -129,6 +343,7 @@ bootbox.hideAll(); } }); + window.pseManager.load(); } ); return false; @@ -138,219 +353,7 @@ // Product AddtoCard - OnSubmit if (typeof window.PSE_FORM !== "undefined"){ - // cache dom elements - var $pse = { - "id": $("#pse-id"), - "product": $("#product"), - "name": $("#pse-name"), - "ref": $("#pse-ref"), - "ean": $("#pse-ean"), - "availability": $("#pse-availability"), - "quantity": $("#pse-quantity"), - "promo": $("#pse-promo"), - "new": $("#pse-new"), - "weight": $("#pse-weight"), - "price": $("#pse-price"), - "priceOld": $("#pse-price-old"), - "submit": $(".btn_add_to_cart"), - "options": {}, - "pseId": null - }; - - var buildProductForm = function buildProductForm() { - var pse = null, - combinationId = null, - combinationValue = null, - combinationValueId = null; - - // get the select for options - $("#pse-options .pse-option").each(function(){ - var $option = $(this); - $pse['options'][$option.data("attribute")] = $option; - $option.on("change", updateProductForm); - }); - - // build select - for (combinationValueId in PSE_COMBINATIONS_VALUE) { - combinationValue = PSE_COMBINATIONS_VALUE[combinationValueId]; - $pse.options[combinationValue[1]] - .append(""); - } - - // initialization for the first default pse - $pse.pseId = $pse.id.val(); - setPseForm(); - }; - - var setPseForm = function setPseForm(id) { - var i = 0, - pse = null, - combinationValueId; - pse = PSE[id || $pse.pseId]; - for (var i=0; i 0 || ! PSE_CHECK_AVAILABILITY) { - $pse.availability - .removeClass("out-of-stock") - .addClass("in-stock") - .attr("href", "http://schema.org/InStock"); - - $pse.quantity.val(pse.quantity); - - $pse.submit.attr("disabled", false); - } else { - $pse.new.removeClass("in-stock") - .addClass("out-of-stock") - .attr("href", "http://schema.org/OutOfStock"); - - $pse.submit.attr("disabled", true); - } - - // price - $pse.priceOld.html(pse.promo); - $pse.price.html(pse.price); - } - - /* - if (qty == 0) { - // Disable button - $btnAddToCart.attr("disabled", true); - - // Update stock information - $stockInformation - .removeClass("in-stock") - .addClass("out-of-stock") - .attr("href", "http://schema.org/OutOfStock"); - - } else { - // Active button - $btnAddToCart.attr("disabled", false); - - // Update Field Quantity if the current value is over Max - if (parseInt($quantityInput.val()) > parseInt(qty)) { - $quantityInput.val(qty); - } - - // Update stock information - $stockInformation - .removeClass("out-of-stock") - .addClass("in-stock") - .attr("href", "http://schema.org/InStock"); - } - - // HTML5 number attribute - $quantityInput.attr("max", qty); - - // Update Prices - $(".old-price > .price", $productDetails).html($current.data('old-price')); - $(".special-price > .price, .regular-price > .price", $productDetails).html($current.data('price')); - */ - - var pseExist = function pseExist(selection) { - var pseId, - pse = null, - combinations, - i, - j, - existCombination; - - for (pse in PSE){ - pseId = pse; - combinations = PSE[pse].combinations; - for (i = 0; i < selection.length; i++){ - existCombination = false; - for (j = 0; j < combinations.length; j++){ - if (selection[i] == combinations[j]){ - existCombination = true; - break; - } - } - if (existCombination === false) { - break; - } - } - if (existCombination) { - return pseId; - } - } - - return false; - } - - var getFormSelection = function getFormSelection() { - var selection = [], - combinationId; - - for (combinationId in $pse.options){ - selection.push($pse.options[combinationId].val()); - } - - return selection; - } - - buildProductForm(); - updateProductForm(); - + window.pseManager.load(); } $(document).on('submit.form-product', '.form-product', function () { @@ -384,55 +387,6 @@ return; }); - /* - - - $(document).on('change.quantity', 'select:has([data-quantity])', function () { - var $productDetails = $(this).closest("#product-details"), - $stockInformation = $("#stock-information", $productDetails), - $quantityInput = $("#quantity", $productDetails), - $btnAddToCart = $(".btn_add_to_cart", $productDetails); - - var $current = $(":selected", this); - var qty = $current.data("quantity"); - - // Show Out Of Stock OR In Stock - if (qty == 0) { - // Disable button - $btnAddToCart.attr("disabled", true); - - // Update stock information - $stockInformation - .removeClass("in-stock") - .addClass("out-of-stock") - .attr("href", "http://schema.org/OutOfStock"); - - } else { - // Active button - $btnAddToCart.attr("disabled", false); - - // Update Field Quantity if the current value is over Max - if (parseInt($quantityInput.val()) > parseInt(qty)) { - $quantityInput.val(qty); - } - - // Update stock information - $stockInformation - .removeClass("out-of-stock") - .addClass("in-stock") - .attr("href", "http://schema.org/InStock"); - } - - // HTML5 number attribute - $quantityInput.attr("max", qty); - - // Update Prices - $(".old-price > .price", $productDetails).html($current.data('old-price')); - $(".special-price > .price, .regular-price > .price", $productDetails).html($current.data('price')); - - }); - */ - // Toolbar var $category_products = $ ('#category-products'); diff --git a/templates/frontOffice/default/assets/less/thelia/product.less b/templates/frontOffice/default/assets/less/thelia/product.less index 86d8f7c6e..cbc91f228 100644 --- a/templates/frontOffice/default/assets/less/thelia/product.less +++ b/templates/frontOffice/default/assets/less/thelia/product.less @@ -16,7 +16,7 @@ // In Stock .in-stock { - color: #44B661; + color: @brand-success; font-style: italic; font-weight: bold; text-transform: uppercase; @@ -29,7 +29,7 @@ } // Out of Stock .out-of-stock { - color: #FF0000; + color: @brand-warning; font-style: italic; font-weight: bold; text-transform: uppercase; diff --git a/templates/frontOffice/default/product.html b/templates/frontOffice/default/product.html index c059d0cd8..41d962ab4 100644 --- a/templates/frontOffice/default/product.html +++ b/templates/frontOffice/default/product.html @@ -132,8 +132,8 @@ - {intl l="Special Price:"} {format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"} - {intl l="Regular Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} + {intl l="Special Price:"} {format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"} + {intl l="Regular Price:"} {format_number number="{$TAXED_PRICE}"} {currency attr="symbol"} @@ -186,7 +186,7 @@ {/form_field}
- +
@@ -267,6 +267,42 @@ {/if} +{* javascript confiuguration to display pse *} +{$pse=[]} +{$combination_label=[]} +{$combination_values=[]} +{loop name="pse" type="product_sale_elements" product="{product attr="id"}"} +{$pse[$ID]=["id" => $ID, "isDefault" => $IS_DEFAULT, "isPromo" => $IS_PROMO, "isNew" => $IS_NEW, "ref" => "{$REF}", "ean" => "{$EAN}", "quantity" => {$QUANTITY}, "price" => "{format_number number="{$TAXED_PRICE}"} {currency attr="symbol"}", "promo" => "{format_number number="{$TAXED_PROMO_PRICE}"} {currency attr="symbol"}" ]} +{$pse_combination=[]} +{loop name="combi" type="attribute_combination" product_sale_elements="$ID"} +{if ! $combination_label[$ATTRIBUTE_ID]} +{$combination_label[$ATTRIBUTE_ID]=["name" => "{$ATTRIBUTE_TITLE}", "values" => []]} +{/if} +{if ! $combination_values[$ATTRIBUTE_AVAILABILITY_ID]} +{$combination_label[$ATTRIBUTE_ID]["values"][]=$ATTRIBUTE_AVAILABILITY_ID} +{$combination_values[$ATTRIBUTE_AVAILABILITY_ID]=["{$ATTRIBUTE_AVAILABILITY_TITLE}", $ATTRIBUTE_ID]} +{/if} +{$pse_combination[]=$ATTRIBUTE_AVAILABILITY_ID} +{/loop} +{$pse[$ID]["combinations"]=$pse_combination} +{/loop} + +{if $pse_count > 1} +{/if} +