Announcement

Collapse
No announcement yet.

Overwrite Customer Bill-To Company name in checkout before final submission (INVC)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Overwrite Customer Bill-To Company name in checkout before final submission (INVC)

    Not sure if this is possible or not. We have wholesale customers who place orders and we store their company name in a customer custom field so that we can map them through to other workflows. We need to be able to force their Bill-To company name field to be the value of the custom field regardless of what the customer enters during checkout. Customers frequently change their Bill-To info and we lose the ability to force the mapping of their wholesale account to other platforms.

    So far on the OPAY template I've tried to force overwrite the g.Basket:bill_comp value with our custom field, but when the order is submitted, the value they entered on the OCST customer information form gets stored on the order regardless. So my tests have not been successful and my hunch is that it's because the customer information gets written to the order after the OCST page and it's not updatable after that. I've thought about moving my code to the OCST template but I didn't want to bother if what I'm trying to do isn't possible anyway. Also, overwriting the Bill-To name that early in the checkout process leaves us open to the customer editing it again thinking they've made a mistake.

    Here's what I've tried so far, and this does temporarily overwrite the Basket:bill_comp value but it gets lost on final order submission and reverted back to what they entered in the customer information form.

    Any thoughts would be appreciated.

    Code:
    <mvt:item name="customfields" param="Read_Customer_ID(g.Basket:cust_id, 'my_custom_field', g.my_CFName)" />
    
    <mvt:comment> temp store bill_comp value so we can show to the customer on final confirmation screen (basically hiding our override so they don't freak out) </mvt:comment>
    <mvt:assign name="g.bill_comp_temp" value="g.Basket:bill_comp" />
    
    <mvt:comment> overwrite g.Basket:bill_comp with value from my_custom_field (assigned to my_CFName above) </mvt:comment>
     <mvt:assign name="g.Basket:bill_comp" value="g.my_CFName" /> 
    
    <mvt:comment> also write the value to a Order/Basket custom field so it gets written to the order separately </mvt:comment>
    <mvt:item name="customfields" param="Write_Basket('QBCust', g.my_QBName)" />
    Hope all that makes sense. Thanks!
    Joe McDonald
    patrickwebby.com

    #2
    jpatrickm Where do you have the code implemented?

    My suggestion would be read the customer custom field on the OCST page. Then if it is available add the value to the customer billing company and make the input read only so that the user cannot alter the information. Then when they submit the information on OCST the billing company will be set to the desired value.

    It could look something like this:

    Code:
    <mvt:item name="customfields" param="Read_Customer_ID(g.Basket:cust_id, 'my_custom_field', g.my_CFName)" />
    
    <label id="BillCompany_label" class="c-form-label u-font-small u-text-italic" for="BillCompany">Company (Optional)</label>
    <mvt:if expr="ISNULL(g.my_CFName)">
        <div class="c-form-list__item o-layout__item u-width-4--m &mvte:global:BillCompany_Row;">
            <input id="BillCompany" class="c-form-input" type="text" name="BillCompany" value="&mvte:global:BillCompany;" aria-describedby="BillingInformation BillCompany_label" autocomplete="organization">
        </div>
    <mvt:else>
        <div class="c-form-list__item o-layout__item u-width-4--m &mvte:global:BillCompany_Row;">
            <input id="BillCompany" class="c-form-input" type="text" name="BillCompany" value="&mvte:global:my_CFName;" readonly aria-describedby="BillingInformation BillCompany_label" autocomplete="organization">
        </div>
        <mvt:comment> also write the value to a Order/Basket custom field so it gets written to the order separately </mvt:comment>
        <mvt:item name="customfields" param="Write_Basket('QBCust', g.my_QBName)" />
    </mvt:if>
    Last edited by Nick; 09-13-23, 01:51 PM.
    Nicholas Adkins
    Technical Training Specialist / Miva, Inc.
    [email protected]
    https://www.miva.com/mivalearn

    Comment


      #3
      Hey Nick, good idea, I'll give that a try. Thanks for the help!
      Joe McDonald
      patrickwebby.com

      Comment

      Working...
      X