Cost Center value autopopulated from customer custom field - xmpie-users/uStore-js GitHub Wiki

uStore provides a cost center clearing method for customers to use when ordering. This allows the customer to enter a cost center number at checkout and you can use this information in uStore reports when billing the customer later.

By default there is only one empty input box and no pre-population of users cost center.

Show JavaScript works by adding a default value to the existing cost center text box. The default value is populated from the Custom User Field (Custom1) of the purchasing customer.

Additional this examples shows how to append a Custom User Field (Custom1) to the Cost Center Clearing using the xmp JavaScript SDK.

<script type="text/javascript">
if(window.location.pathname.indexOf("CheckoutPaymentSubmission.aspx") > 0){
   $( document ).ready(function() {
		document.getElementById("ctl00_cphMainContent_ctlClearingUserData10000_txtCostCenter").defaultValue = xmp.sdk.storeFrontParams.currentUser.custom1
   });
}
</script>

For information on how to add JavaScript to your store: How to add JavaScript to a storefront.

⚠️ **GitHub.com Fallback** ⚠️