From 0b8ce2c91fba8a7ac41f9a2ebe585348a4367dab Mon Sep 17 00:00:00 2001 From: Ashish Vijaywargiya Date: Mon, 30 Nov 2009 13:41:56 +0000 Subject: [PATCH] Applied patch from jira issue - OFBIZ-3249 - Shopping cart on checkout page does not gets update when a gift item is added in cart after applying coupon code. Patch for update cart on one page checkout page when a gift item a added in cart after applying valid coupon code. Steps to test: 1. Create a new product promo for 'Gift With Purchase' action with require coupon code. 2. Go to ecommerce -> main 3. Purchase X product and go for one page checkout page. 4. Enter coupon code 5 If this coupon code is valid according to condition given in promotion then a you will get Y product as gift in cart with 0.0 price. Thanks Arun for the contribution. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@885425 13f79535-47bb-0310-9956-ffa450edef68 --- .../webapp/ecommerce/WEB-INF/controller.xml | 5 + .../webapp/ecommerce/cart/UpdateCart.ftl | 184 ++++++++++++++++++ .../ecommerce/images/checkoutProcess.js | 17 +- ecommerce/widget/CartScreens.xml | 16 ++ 4 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 ecommerce/webapp/ecommerce/cart/UpdateCart.ftl diff --git a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml index c86a18892..937552a72 100644 --- a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml +++ b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml @@ -295,6 +295,10 @@ under the License. + + + + @@ -1903,6 +1907,7 @@ under the License. + diff --git a/ecommerce/webapp/ecommerce/cart/UpdateCart.ftl b/ecommerce/webapp/ecommerce/cart/UpdateCart.ftl new file mode 100644 index 000000000..0d1088770 --- /dev/null +++ b/ecommerce/webapp/ecommerce/cart/UpdateCart.ftl @@ -0,0 +1,184 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<#if shoppingCart?has_content && shoppingCart.size() > 0> +

${uiLabelMap.EcommerceStep} 1: ${uiLabelMap.PageTitleShoppingCart}

+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <#list shoppingCart.items() as cartLine> + + + + + + <#if !cartLine.getIsPromo()> + + <#else> + + + + <#if !cartLine.getIsPromo()> + + + + + +
${uiLabelMap.OrderItem}${uiLabelMap.CommonDescription}${uiLabelMap.EcommerceUnitPrice}${uiLabelMap.OrderQuantity}${uiLabelMap.EcommerceAdjustments}${uiLabelMap.EcommerceItemTotal}${uiLabelMap.FormFieldTitle_removeButton}
${uiLabelMap.CommonSubtotal}<@ofbizCurrency amount=shoppingCart.getSubTotal() isoCode=shoppingCart.getCurrency() />
${uiLabelMap.ProductDiscount} + <#assign orderAdjustmentsTotal = 0 /> + <#list shoppingCart.getAdjustments() as cartAdjustment> + <#assign orderAdjustmentsTotal = orderAdjustmentsTotal + Static["org.ofbiz.order.order.OrderReadHelper"].calcOrderAdjustment(cartAdjustment, shoppingCart.getSubTotal()) /> + + <@ofbizCurrency amount=orderAdjustmentsTotal isoCode=shoppingCart.getCurrency() /> +
${uiLabelMap.OrderShippingAndHandling}<@ofbizCurrency amount=shoppingCart.getTotalShipping() isoCode=shoppingCart.getCurrency() />
${uiLabelMap.OrderSalesTax}<@ofbizCurrency amount=shoppingCart.getTotalSalesTax() isoCode=shoppingCart.getCurrency() />
${uiLabelMap.OrderGrandTotal}<@ofbizCurrency amount=shoppingCart.getDisplayGrandTotal() isoCode=shoppingCart.getCurrency() />
+ <#if cartLine.getProductId()?exists> + <#if cartLine.getParentProductId()?exists> + <#assign parentProductId = cartLine.getParentProductId() /> + <#else> + <#assign parentProductId = cartLine.getProductId() /> + + <#assign smallImageUrl = Static["org.ofbiz.product.product.ProductContentWrapper"].getProductContentAsText(cartLine.getProduct(), "SMALL_IMAGE_URL", locale, dispatcher)?if_exists /> + <#if !smallImageUrl?string?has_content><#assign smallImageUrl = "" /> + <#if smallImageUrl?string?has_content> + Product Image + + + ${cartLine.getName()?if_exists}<@ofbizCurrency amount=cartLine.getDisplayPrice() isoCode=shoppingCart.getCurrency() /> + <#if cartLine.getIsPromo()> + ${cartLine.getQuantity()?string.number} + <#else> + + + + + + <@ofbizCurrency amount=cartLine.getOtherAdjustments() isoCode=shoppingCart.getCurrency() /><@ofbizCurrency amount=cartLine.getOtherAdjustments() isoCode=shoppingCart.getCurrency() /><@ofbizCurrency amount=cartLine.getDisplayItemSubTotal() isoCode=shoppingCart.getCurrency() />Remove Item Image
+
+
+
+ + +
+
+
+ ${uiLabelMap.EcommerceContinueToStep} 2 + +
+
+
+ \ No newline at end of file diff --git a/ecommerce/webapp/ecommerce/images/checkoutProcess.js b/ecommerce/webapp/ecommerce/images/checkoutProcess.js index 1ec2502c7..611b014ff 100644 --- a/ecommerce/webapp/ecommerce/images/checkoutProcess.js +++ b/ecommerce/webapp/ecommerce/images/checkoutProcess.js @@ -382,6 +382,11 @@ function processBillingAndPayment() { function initCartProcessObservers() { var cartForm = $('cartForm'); Event.observe($('productPromoCode'), 'change', addPromoCode); + Event.observe($('updateShoppingCart'), 'click', showEditShippingPanel); + Event.observe($('openCartPanel'), 'click', function() { + showEditCartPanel(); + updateShippingSummary(); + }); var inputs = cartForm.getInputs('text'); inputs.each(function(e) { if(e.id != 'productPromoCode') { @@ -479,8 +484,14 @@ function updateCartData(elementId, formValues, itemQty, itemIndex) { $('googleCheckoutDisabled').show(); $('microCartPayPalCheckout').hide(); } else { - // Used for edit cart - $('microCartQuantity').update(data.totalQuantity); + // Replace whole cart panel with updated cart values for updating line item in case of gift item is added or remove in cart after applying coupon code + // No need to calculate indivisual value for shopping cart when whole cart is updating + new Ajax.Updater($('cartPanel'), 'UpdateCart', {evalScripts: true, method: '', onComplete:function() + { + initCartProcessObservers(); + } + }); + /*$('microCartQuantity').update(data.totalQuantity); $('cartSubTotal').update(data.subTotalCurrencyFormatted); $('cartDiscountValue').update(data.displayOrderAdjustmentsTotalCurrencyFormatted); $('cartTotalShipping').update(data.totalShippingCurrencyFormatted); @@ -519,7 +530,7 @@ function updateCartData(elementId, formValues, itemQty, itemIndex) { var completedCartItemSubTotalId = elementId.sub('qty_','completedCartItemSubTotal_'); $(completedCartItemSubTotalId).update(lineItemTotal); } - } + }*/ } }, parameters: formValues diff --git a/ecommerce/widget/CartScreens.xml b/ecommerce/widget/CartScreens.xml index 15472e656..736ae22c7 100644 --- a/ecommerce/widget/CartScreens.xml +++ b/ecommerce/widget/CartScreens.xml @@ -122,4 +122,20 @@ under the License. + + +
+ + + + + + +