From d4274b60541440c12dc38751bcfcd91ce22ef0a1 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Fri, 20 Apr 2012 14:55:21 +0000 Subject: [PATCH] [-] FO : #PSFV-803 - Fix bugs with customization and cart summary git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14788 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Cart.php | 4 +- themes/default/css/global.css | 13 +++++- themes/default/js/cart-summary.js | 42 +++++++++++++++---- themes/default/shopping-cart-product-line.tpl | 2 +- themes/default/shopping-cart.tpl | 7 +++- 5 files changed, 54 insertions(+), 14 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 6ccb66bb3..411970470 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1117,12 +1117,12 @@ class CartCore extends ObjectModel AND `id_product_attribute` = '.(int)$id_product_attribute.' '.((int)$id_address_delivery ? 'AND `id_address_delivery` = '.(int)$id_address_delivery : '')); - if (!$this->_deleteCustomization((int)$id_customization, (int)$id_product, (int)$id_product_attribute)) + if (!$this->_deleteCustomization((int)$id_customization, (int)$id_product, (int)$id_product_attribute, $id_address_delivery)) return false; // refresh cache of self::_products $this->_products = $this->getProducts(true); - return ($customization_quantity == $product_total_quantity && $this->deleteProduct((int)$id_product, $id_product_attribute, null)); + return ($customization_quantity == $product_total_quantity && $this->deleteProduct((int)$id_product, $id_product_attribute, $id_address_delivery)); } /* Get customization quantity */ diff --git a/themes/default/css/global.css b/themes/default/css/global.css index f0cabd5e1..e5551c057 100644 --- a/themes/default/css/global.css +++ b/themes/default/css/global.css @@ -675,14 +675,22 @@ table#cart_summary td.price_discount_del {border-right:none} table#cart_summary .last_item td {border-bottom:1px solid #999} -table#cart_summary tr:nth-child(odd), +table#cart_summary tr.cart_item.odd, table#cart_summary tr.cart_total_delivery, table#cart_summary tr.cart_total_price { background-color: #fff } -table#cart_summary tr:nth-child(even) { +table#cart_summary tr.cart_item.even { background-color: #f3f3f3 } + +table#cart_summary tr.customization.odd { + background-color: #fff +} +table#cart_summary tr.customization.even { + background-color: #f3f3f3 +} + table#cart_summary tr ul { list-style: none; } @@ -696,6 +704,7 @@ table#cart_summary .cart_description { } table#cart_summary .cart_unit {width:130px} table#cart_summary .cart_quantity {width:130px} +table#cart_summary .customization .cart_quantity {padding: 8px 12px 0;} .cart_quantity .cart_quantity_input { float:left; margin-left: 5px; diff --git a/themes/default/js/cart-summary.js b/themes/default/js/cart-summary.js index e857f374c..48444cb8f 100644 --- a/themes/default/js/cart-summary.js +++ b/themes/default/js/cart-summary.js @@ -295,19 +295,24 @@ function deleteProductFromSummary(id) else { $('#product_'+ id).fadeOut('slow', function() { - $(this).remove(); - cleanSelectAddressDelivery(); - }); + $(this).remove(); + cleanSelectAddressDelivery(); + if (!customizationId) + refreshOddRow(); + }); var exist = false; for (i=0;i delete product line - if (!exist) - $('#product_'+ productId+'_'+productAttributeId).fadeOut('slow', function() { + // if all customization removed => delete product line + if (!exist && customizationId) + $('#product_' + productId + '_' + productAttributeId + '_0_' + id_address_delivery).fadeOut('slow', function() { $(this).remove(); + refreshOddRow(); }); } updateCartSummary(jsonData.summary); @@ -322,6 +327,29 @@ function deleteProductFromSummary(id) }); } +function refreshOddRow() +{ + var odd_class = 'odd'; + var even_class = 'even'; + $.each($('.cart_item'), function(i, it) + { + if (i == 0) // First item + { + if ($(this).hasClass('even')) + { + odd_class = 'even'; + even_class = 'odd'; + } + $(this).addClass('first_item'); + } + if(i % 2) + $(this).removeClass(odd_class).addClass(even_class); + else + $(this).removeClass(even_class).addClass(odd_class); + }); + $('.cart_item:last-child, .customization:last-child').addClass('last_item'); +} + function upQuantity(id, qty) { if (typeof(qty) == 'undefined' || !qty) diff --git a/themes/default/shopping-cart-product-line.tpl b/themes/default/shopping-cart-product-line.tpl index e4ca798ee..f7f95b1a7 100644 --- a/themes/default/shopping-cart-product-line.tpl +++ b/themes/default/shopping-cart-product-line.tpl @@ -24,7 +24,7 @@ * International Registered Trademark & Property of PrestaShop SA *} - + {$product.name|escape:'htmlall':'UTF-8'} diff --git a/themes/default/shopping-cart.tpl b/themes/default/shopping-cart.tpl index 9b0f9f80e..8a328035c 100644 --- a/themes/default/shopping-cart.tpl +++ b/themes/default/shopping-cart.tpl @@ -222,13 +222,16 @@ {assign var='productId' value=$product.id_product} {assign var='productAttributeId' value=$product.id_product_attribute} {assign var='quantityDisplayed' value=0} + {assign var='odd' value=$product@iteration%2} + {assign var='ignoreProductLast' value=isset($customizedDatas.$productId.$productAttributeId)} {* Display the product line *} {include file="./shopping-cart-product-line.tpl" productLast=$product@last productFirst=$product@first} {* Then the customized datas ones*} {if isset($customizedDatas.$productId.$productAttributeId)} {foreach $customizedDatas.$productId.$productAttributeId[$product.id_address_delivery] as $id_customization=>$customization} - - + + + {foreach $customization.datas as $type=>$custom_data} {if $type == $CUSTOMIZE_FILE}