From e76b4408f4beba534c150656916f3f8f65707cd0 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Tue, 22 May 2012 14:07:16 +0000 Subject: [PATCH] // Fix bug with cart, multishipping and gift product git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15625 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Cart.php | 5 +- controllers/front/CartController.php | 2 +- themes/default/js/cart-summary.js | 16 +++++ .../order-address-multishipping-products.tpl | 59 ++----------------- themes/default/order-address-product-line.tpl | 6 +- themes/default/shopping-cart.tpl | 2 +- 6 files changed, 26 insertions(+), 64 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index ac87f21c7..9e134c97a 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2629,7 +2629,7 @@ class CartCore extends ObjectModel * * @return array Cart details */ - public function getSummaryDetails($id_lang = null) + public function getSummaryDetails($id_lang = null, $refresh = false) { $context = Context::getContext(); if (!$id_lang) @@ -2649,7 +2649,7 @@ class CartCore extends ObjectModel $currency = new Currency($this->id_currency); - $products = $this->getProducts(false); + $products = $this->getProducts($refresh); $gift_products = array(); $cart_rules = $this->getCartRules(); $total_shipping = $this->getTotalShippingCost(); @@ -2723,6 +2723,7 @@ class CartCore extends ObjectModel 'formattedAddresses' => $formatted_addresses, 'products' => array_values($products), 'gift_products' => $gift_products, + //'products_raw' => $this->getProducts(false), 'discounts' => $cart_rules, 'is_virtual_cart' => (int)$this->isVirtualCart(), 'total_discounts' => $total_discounts, diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index e6900f0db..020927664 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -300,7 +300,7 @@ class CartControllerCore extends FrontController Cart::addExtraCarriers($result); } - $result['summary'] = $this->context->cart->getSummaryDetails(); + $result['summary'] = $this->context->cart->getSummaryDetails(null, true); $result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true); $result['HOOK_SHOPPING_CART'] = Hook::exec('displayShoppingCartFooter', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Hook::exec('displayShoppingCart', $result['summary']); diff --git a/themes/default/js/cart-summary.js b/themes/default/js/cart-summary.js index ad7f7f5b3..16104edae 100644 --- a/themes/default/js/cart-summary.js +++ b/themes/default/js/cart-summary.js @@ -523,6 +523,7 @@ function updateCartSummary(json) if (typeof json == 'undefined') return; + $('.cart_quantity_input').val(0); for (i=0;i
- +
@@ -42,64 +42,13 @@ - {foreach from=$product_list item=product name=productLoop} + {foreach $product_list as $product} {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} {* Display the product line *} - {include file="$tpl_dir./order-address-product-line.tpl" productLast=$smarty.foreach.productLoop.last productFirst=$smarty.foreach.productLoop.first} - {* Then the customized datas ones*} - {if isset($customizedDatas.$productId.$productAttributeId)} - {foreach from=$customizedDatas.$productId.$productAttributeId[$product.id_address_delivery] key='id_customization' item='customization'} - - - - - - {assign var='quantityDisplayed' value=$quantityDisplayed+$customization.quantity} - {/foreach} - {* If it exists also some uncustomized products *} - {if $product.quantity-$quantityDisplayed > 0} - {include file="$tpl_dir./order-address-product-line.tpl" productLast=$smarty.foreach.productLoop.last productFirst=$smarty.foreach.productLoop.first} - {/if} - - {/if} + {include file="$tpl_dir./order-address-product-line.tpl" productLast=$product@last productFirst=$product@first} {/foreach}
{l s='Product'}
- {foreach from=$customization.datas key='type' item='datas'} - {if $type == $CUSTOMIZE_FILE} -
-
    - {foreach from=$datas item='picture'}
  • {/foreach} -
-
- {elseif $type == $CUSTOMIZE_TEXTFIELD} -
    - {foreach from=$datas item='textField' name='typedText'}
  • {if $textField.name}{$textField.name}{l s=':'}{else}{l s='Text #%s:' sprintf=$smarty.foreach.typedText.index+1}{/if} {$textField.value}
  • {/foreach} -
- {/if} - {/foreach} -
- {if isset($cannotModify) AND $cannotModify == 1} - {if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if} - {else} -
- {l s='Delete'} -
-
- {l s='Add'}
- {if $product.minimal_quantity < ($customization.quantity -$quantityDisplayed) OR $product.minimal_quantity <= 1} - - {l s='Subtract'} - - {else} - - {l s='Subtract'} - - {/if} -
- - - {/if} -
diff --git a/themes/default/order-address-product-line.tpl b/themes/default/order-address-product-line.tpl index 98901b9f6..25e71a1d9 100644 --- a/themes/default/order-address-product-line.tpl +++ b/themes/default/order-address-product-line.tpl @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} - + {$product.name|escape:'htmlall':'UTF-8'} @@ -36,7 +36,6 @@ {if isset($cannotModify) AND $cannotModify == 1} {if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if} {else} - {if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}{$product.customizationQuantityTotal}{/if} {if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0}
{l s='Add'}
@@ -79,8 +78,5 @@ - {if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0} - {l s='Delete'} - {/if} \ No newline at end of file diff --git a/themes/default/shopping-cart.tpl b/themes/default/shopping-cart.tpl index db683da7c..58ac68ec9 100644 --- a/themes/default/shopping-cart.tpl +++ b/themes/default/shopping-cart.tpl @@ -236,7 +236,7 @@ {* 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}