This is an automated email from the ASF dual-hosted git repository. nmalin pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push: new 20e00c8 Fixed: Add to cart is not working for products with selectable features (OFBIZ-11970) 20e00c8 is described below commit 20e00c82a3950e413395cdfd7e79a424ec9178f4 Author: Nicolas Malin <nicolas.ma...@nereide.fr> AuthorDate: Tue Sep 28 14:11:52 2021 +0200 Fixed: Add to cart is not working for products with selectable features (OFBIZ-11970) Two issues were present, first was due to incorrect markup and the second was due to ajax request and response view of the additem request. In additem request last saved view or the view of the last request is rendered on successful operation and in this case the last request/view is the one which is used to render UOM dropdown. Thanks: Akash Jain and Ravi Lodhi --- ecommerce/template/catalog/ProductDetail.ftl | 4 ++-- .../template/catalog/ProductUomDropDownOnly.ftl | 28 ++++++++++++++++++++++ ecommerce/webapp/ecommerce/WEB-INF/controller.xml | 4 ++-- ecommerce/widget/CatalogScreens.xml | 25 +++++++++++++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/ecommerce/template/catalog/ProductDetail.ftl b/ecommerce/template/catalog/ProductDetail.ftl index ea8bda4..188d030 100644 --- a/ecommerce/template/catalog/ProductDetail.ftl +++ b/ecommerce/template/catalog/ProductDetail.ftl @@ -617,10 +617,10 @@ ${variantInfoJavaScript!} </div> </#if> <#-- Variant Selection --> - <div class="form-group"> <#if "Y" == product.isVirtual!?upper_case> <#if "VV_FEATURETREE" == product.virtualVariantMethodEnum! && featureLists?has_content> <#list featureLists as featureList> + <div class="form-group"> <#list featureList as feature> <#if feature_index == 0> ${feature.description}: @@ -660,7 +660,7 @@ ${variantInfoJavaScript!} <#if !product.virtualVariantMethodEnum?? || "VV_VARIANTTREE" == product.virtualVariantMethodEnum> <#if variantTree?? && (variantTree.size() > 0)> <#list featureSet as currentType> - <div> + <div class="form-group"> <select name="FT${currentType}" class="form-control" onchange="javascript:getList(this.name, (this.selectedIndex-1), 1);"> <option>${featureTypes.get(currentType)}</option> </select> diff --git a/ecommerce/template/catalog/ProductUomDropDownOnly.ftl b/ecommerce/template/catalog/ProductUomDropDownOnly.ftl new file mode 100644 index 0000000..49522db --- /dev/null +++ b/ecommerce/template/catalog/ProductUomDropDownOnly.ftl @@ -0,0 +1,28 @@ +<#-- +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 product?? && mainProducts??> + <div class="form-group"> + <select name="parentProductId" onchange="javascript:variantUomSelection(this);" class="form-control"> + <option value="">${uiLabelMap.CommonSelect} ${uiLabelMap.ProductUnitOfMeasure}</option> + <#list mainProducts as mainProduct> + <option value="${mainProduct.productId}">${mainProduct.uomDesc} : ${mainProduct.piecesIncluded}</option> + </#list> + </select> + </div> +</#if> \ No newline at end of file diff --git a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml index 200f829..b2f1f78 100644 --- a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml +++ b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml @@ -1812,7 +1812,7 @@ under the License. <request-map uri="ProductUomDropDownOnly"> <security auth="false" https="false"/> - <response name="success" type="view" value="ProductUomDropDownOnly" save-current-view="false" /> + <response name="success" type="view" value="ProductUomDropDownOnly" save-current-view="false" save-last-view="true"/> </request-map> <!-- Captcha: Image request, the captcha code is stored in the session using _CAPTCHA_CODE_ as the key --> @@ -2016,7 +2016,7 @@ under the License. <view-map name="compareProducts" type="screen" page="component://ecommerce/widget/OrderScreens.xml#compareProducts"/> <!-- Product in the different UOM --> - <view-map name="ProductUomDropDownOnly" type="screen" page="component://order/widget/ordermgr/OrderEntryCatalogScreens.xml#ProductUomDropDownOnly"/> + <view-map name="ProductUomDropDownOnly" type="screen" page="component://ecommerce/widget/CatalogScreens.xml#ProductUomDropDownOnly"/> <!-- Contact List --> <view-map name="ContactListOptOut" type="screen" page="component://marketing/widget/ContactListScreens.xml#OptOutResponse"/> diff --git a/ecommerce/widget/CatalogScreens.xml b/ecommerce/widget/CatalogScreens.xml index e162984..72befeb 100644 --- a/ecommerce/widget/CatalogScreens.xml +++ b/ecommerce/widget/CatalogScreens.xml @@ -641,4 +641,29 @@ under the License. </widgets> </section> </screen> + + <screen name="ProductUomDropDownOnly"> + <section> + <actions> + <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/> + <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/> + <script location="component://order/groovyScripts/entry/catalog/ProductUomDropDownOnly.groovy"/> + <!-- This screen is used to update uom dropdown using ajax request. Setting the last saved view in the last view to avoid + ajax request's view to be used in subsequent request with response type last view.--> + <set field="nothing" value="${groovy: session.setAttribute('_LAST_VIEW_NAME_', session.getAttribute('_SAVED_VIEW_NAME_'))}"/> + </actions> + <widgets> + <section> + <condition> + <not><if-empty field="product"/></not> + </condition> + <widgets> + <platform-specific> + <html><html-template location="component://ecommerce/template/catalog/ProductUomDropDownOnly.ftl"/></html> + </platform-specific> + </widgets> + </section> + </widgets> + </section> + </screen> </screens>