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
This commit is contained in:
Nicolas Malin
2021-09-28 14:12:10 +02:00
parent 6d5aca3d2a
commit b8e47a4eaa
4 changed files with 57 additions and 4 deletions
+2 -2
View File
@@ -618,10 +618,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}:
@@ -661,7 +661,7 @@ ${variantInfoJavaScript!}
<#if !product.virtualVariantMethodEnum?? || "VV_VARIANTTREE" == product.virtualVariantMethodEnum>
<#if variantTree?? && (variantTree.size() &gt; 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>
@@ -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>
@@ -1789,7 +1789,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 -->
@@ -1993,7 +1993,7 @@ under the License.
<view-map name="compareProducts" type="screen" page="component://order/widget/ordermgr/OrderEntryCatalogScreens.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"/>
+25
View File
@@ -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>