I’m trying to prefill a custom field on the checkout page called partnercode in WIX ecommerce
When I share an URL with a parameter for partnercode=123test I want this value to be prefilled in the field partnercode on the checkoutpage
URL for checkout page:
https://www.libertech.online/checkout?appSectionParams={"a11y"%3Atrue%2C"storeUrl"%3A"https%3A%2F%2Fwww.libertech.online"%2C"isPickupFlow"%3Afalse%2C"cashierPaymentId"%3A""%2C"origin"%3A"productPage"%2C"originType"%3A"subscriptionPlans"%2C"checkoutId"%3A"5deb0c99-f9bc-492d-8286-edf719efe107"}&checkoutOOI=true&partnercode=123test
I have tried to implement a custom code snippet on the body-start of the checkout page:
import wixLocation from 'wix-location';
$w.onReady(function () {
console.log(wixLocation.query);
$w("#partnercode").value = wixLocation.query["partnercode"];
});
Unfortunately the field partnercode is not prefilled.
Unfortunately still not working for me
How does your code know it need to put the variable for partnercode into the ‘First Name’ field? Could you please share your code snippet, custom code settings and your form setup so I can cross check my settings?
You can specify the field by using the field’s ID as in:
$w("#fieldIdHere").value = wixLocation.query["partnercode"];
All field IDs start with a #
and you can find the ID for a field by selecting the element, opening the code panel, and looking at the ID field towards the bottom left of the screen. You can see here that mine is called #input1
. You can also rename this field if you need to.