From 7e73e088e519c65e8fbcd4d72caa60f43cf48e93 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Wed, 22 Feb 2012 11:02:49 +0000 Subject: [PATCH] [-] FO : ajax cart now display cart rules correctly #PSTEST-724 // Small addition to the controller override git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13527 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/cache/Cache.php | 5 ++++ modules/blockcart/ajax-cart.js | 20 +++++++++----- modules/blockcart/blockcart-json.tpl | 5 +++- modules/blockcart/blockcart.css | 8 ++++++ modules/blockcart/blockcart.php | 29 +++++++++++++++++++-- modules/blockcart/blockcart.tpl | 15 +++++++++-- modules/blockcart/translations/fr.php | 2 ++ override/classes/controller/_Controller.php | 9 +++++-- 8 files changed, 80 insertions(+), 13 deletions(-) diff --git a/classes/cache/Cache.php b/classes/cache/Cache.php index eba4aa1aa..5cebeb255 100755 --- a/classes/cache/Cache.php +++ b/classes/cache/Cache.php @@ -307,6 +307,11 @@ abstract class CacheCore return isset(Cache::$local[$key]) ? Cache::$local[$key] : null; } + public static function retrieveAll() + { + return Cache::$local; + } + public static function isStored($key) { return isset(Cache::$local[$key]); diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index 0083e1f85..78cc7ae41 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -375,7 +375,7 @@ var ajaxCart = { var toDelete = true; for (i=0;i 0) { $('#bloc_cart_voucher_' + idElmt + ' td.price').text(jsonData.discounts[i].price); toDelete = false; @@ -429,7 +429,7 @@ var ajaxCart = { var domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0'); var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0'); - if($('#cart_block dt#cart_block_product_'+ domIdProduct ).length == 0) + if ($('#cart_block dt#cart_block_product_'+ domIdProduct ).length == 0) { var productId = parseInt(this.id); var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0); @@ -438,7 +438,7 @@ var ajaxCart = { var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name); content += '' + name + ''; content += ' '; - content += '' + this.priceByLine + ''; + content += '' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + ''; content += ''; if (this.hasAttributes) content += '
@@ -100,11 +108,14 @@ var removingLinkText = '{l s='remove this product from my cart' mod='blockcart' {if $discounts|@count > 0} {foreach from=$discounts item=discount} + {if $discount.value_real > 0} + - + + {/if} {/foreach}
1x {$discount.name|cat:' : '|cat:$discount.description|truncate:18:'...'|escape:'htmlall':'UTF-8'}-{if $discount.value_real != '!'}{if $priceDisplay == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_real}{/if}{/if}-{if $priceDisplay == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_real}{/if} {l s='Delete'}
diff --git a/modules/blockcart/translations/fr.php b/modules/blockcart/translations/fr.php index 52b9360c7..3008defa7 100644 --- a/modules/blockcart/translations/fr.php +++ b/modules/blockcart/translations/fr.php @@ -15,6 +15,8 @@ $_MODULE['<{blockcart}prestashop>blockcart_dba281afb9a38e654ea9dab4cd6cb0ca'] = $_MODULE['<{blockcart}prestashop>blockcart_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer'; $_MODULE['<{blockcart}prestashop>blockcart_20351b3328c35ab617549920f5cb4939'] = 'Personnalisation '; $_MODULE['<{blockcart}prestashop>blockcart_ed6e9a09a111035684bb23682561e12d'] = 'supprimer cet article du panier'; +$_MODULE['<{blockcart}prestashop>blockcart_c6995d6cc084c192bc2e742f052a5c74'] = 'Offert !'; +$_MODULE['<{blockcart}prestashop>blockcart_e7a6ca4e744870d455a57b644f696457'] = 'Offert !'; $_MODULE['<{blockcart}prestashop>blockcart_a85eba4c6c699122b2bb1387ea4813ad'] = 'Panier'; $_MODULE['<{blockcart}prestashop>blockcart_86024cad1e83101d97359d7351051156'] = 'articles'; $_MODULE['<{blockcart}prestashop>blockcart_f5bf48aa40cad7891eb709fcf1fde128'] = 'article'; diff --git a/override/classes/controller/_Controller.php b/override/classes/controller/_Controller.php index c7fd8874a..bc1490ba9 100644 --- a/override/classes/controller/_Controller.php +++ b/override/classes/controller/_Controller.php @@ -304,6 +304,9 @@ abstract class Controller extends ControllerCore $globalSize[$key] = round($size / 1024, 1); } arsort($globalSize); + + $cache = Cache::retrieveAll(); + $totalCacheSize = $this->sizeofvar($cache); echo '

@@ -326,7 +329,7 @@ abstract class Controller extends ControllerCore echo '
- Memory peak usage: '.$this->displayMemoryColor(memory_get_peak_usage()).''; + Memory peak usage: '.$this->displayMemoryColor(memory_get_peak_usage()); if (self::$_footer) { echo '
    '; @@ -338,7 +341,9 @@ abstract class Controller extends ControllerCore } echo '
'; } - echo '
'; + echo '

+ Total cache size (in Cache class): '.$this->displayMemoryColor($totalCacheSize).' + '; echo '