[ofbiz-plugins] branch trunk updated: Improved: Can't enter decimals when ordering on ecommerce (OFBIZ-11899)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-plugins] branch trunk updated: Improved: Can't enter decimals when ordering on ecommerce (OFBIZ-11899)

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux 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 5366f7d  Improved: Can't enter decimals when ordering on ecommerce (OFBIZ-11899)
5366f7d is described below

commit 5366f7d85e126f065f6272fe57f4924e2f921011
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Sat Aug 8 16:58:51 2020 +0200

    Improved: Can't enter decimals when ordering on ecommerce (OFBIZ-11899)
   
    In stable demo, and R18 locally, you can order a half pizza, that's no longer
    possible in trunk demo.
   
    Moreover you can't use the Add button in trunk, And if you use the Config button
    then it orders. There must be a mix between the 2 buttons, maybe the reason
    why we can't no longer enter decimals in trunk...
   
    Suraj: Added a patch with some refactoring of js code and used form attribute to
    get quantity value for addform.
    This might work with the provided patch but I think a better solution could be
    through markup. Also, due to some time constraints, I was not able to dig deep
    into how it is working in another branch.
   
    It's a workaround that we can use to continue over OFBIZ-11916.
    But I don't like that we have both add_amount and quantity fields out of the
    addform form. Actually as I explained at https://markmail.org/message/lnz57yzj3uywcr2y
    I don't even understand how this is possible since the FTL source sounds correct...
   
    Thanks: Suraj for the temporary workaround
---
 ecommerce/template/catalog/ConfigProductDetail.ftl | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/ecommerce/template/catalog/ConfigProductDetail.ftl b/ecommerce/template/catalog/ConfigProductDetail.ftl
index 385d837..44427f8 100644
--- a/ecommerce/template/catalog/ConfigProductDetail.ftl
+++ b/ecommerce/template/catalog/ConfigProductDetail.ftl
@@ -47,9 +47,15 @@ ${virtualJavaScript!}
   }
 
   function addItem() {
-    document.configform.action = document.addform.action;
-    document.configform.quantity.value = document.addform.quantity.value;
-    document.configform.submit();
+    var addForm = jQuery('#addFormId');
+    var formData = addForm.serializeArray();
+    var quantity = formData.find(function(item){
+        return "quantity" == item.name;
+    })
+    var configForm = jQuery('#configFormId');
+    configForm.attr("action", addForm.attr("action"));
+    configForm.find("[name='quantity']").val(quantity.value);
+    configForm.submit();
   }
   function verifyConfig() {
     document.configform.submit();
@@ -304,7 +310,7 @@ ${virtualJavaScript!}
 
         <form method="post"
             action="<@ofbizUrl>additem<#if requestAttributes._CURRENT_VIEW_??>/${requestAttributes._CURRENT_VIEW_}</#if></@ofbizUrl>"
-            name="addform">
+            name="addform" id="addFormId">
         <#assign inStock = true>
         <#-- Variant Selection -->
         <#if product.isVirtual?? && "Y" == product.isVirtual?upper_case>
@@ -366,7 +372,7 @@ ${virtualJavaScript!}
             <div>[${uiLabelMap.EcommerceProductNotConfigured}]&nbsp;
               <input type="text" size="5" name="quantity" value="0" disabled="disabled"/></div>
           <#else>
-            <div class="input-group"><input type="text" size="5" name="quantity" value="1" class="form-control form-control-sm"/>
+            <div class="input-group"><input type="text" size="5" form="addFormId" name="quantity" value="1" class="form-control form-control-sm"/>
             <span class="input-group-button">
             <a href="javascript:addItem()" class="btn btn-outline-secondary btn-sm">
                   ${uiLabelMap.OrderAddToCart}