I see some store can add the ‘section section–custom-fields’ on the checkout page, and I open the checkout.liquid found the ‘section section–custom-fields’ in the {{ content_for_layout }}.
But I can’t edit the {{ content_for_layout }}.
How can I add the ‘section section–custom-fields’ on the checkout page?
checkout.liquid is only accessible to stores on Shopify Plus. (see docs)
If you’re not on Plus, then you’ll have to add fields to the cart page instead. There are a number of ways to handle this, and the Customer Fields app may prove helpful if you need to collect certain data from customers prior to checkout. One thing you might consider is requiring customer accounts before checkout and adding those custom fields to your registration page.
Hello, I just wanted to add that, if you have access to the checkout.liquid file, I am creating a JS library to modify the checkout page with ease. I already have a couple of functionality working that might help you. More is coming soon.
Differentiate load events for each step/page of checkout
Error event for any exception that was not catch in load handlers
Modify fields inside Information and Payment (billing address fields) steps
Add/remove error message and state
Create new fields (text, checkbox, dropdowns) and saving the data in checkout attributes
Insert a field before/after a field
Add tooltips for text fields
Retrieve the Shipping methods inside the load:shipping event
Add a description to shipping methods
Get/set shipping method checked status
Event when a shipping method is changed with the selected shipping method information
Retrieve the Payment methods inside the load:payment event
Add a description to payment methods with content boxes
Get/set payment method checked status
Event when a payment method is changed with the selected payment method information
For example you can add a custom field in the information step that will be saved in the order notes like this:
$checkout.on('load:information', function (e) {
var field = new TextField({
name: 'document',
//Optional properties
type: 'text',
placeholder: 'Enter your document number',
label: 'Document Number',
size: 30,
defaultValue: '',
tooltip: 'We need your document number for regulatory reasons'
});
//Insert before Phone field
$checkout.fields["checkout_billing_address_phone"].insertBefore(field);
})
What requirements do you mean? You should know that in order to list an app on the App Store, it must be available to ALL Shopify merchants (you cannot launch a public app for just Plus stores) unless you’re building a Plus Certified App.
This is a great addition to the checkout page! Awesome job. I’ve been looking for ways to modify the checkout page, but I am stuck with inline item custom fields without the plus membership. My challenge is passing those custom field data into a Shopify webhook that is pushing most of the form data. I would like to have those custom fields be within the webhook post data. If it’s not available could we make an additional HTTP post with the custom fields data to any endpoint? That would be an excellent addition to the library!
What I need:
Ability to add custom fields at checkout
Ability to send those custom data fields to an API/endpoint.
Challenges:
I can only add custom fields to the inline item page.
Those fields are not passed over to the Shopify checkout webhook.
Hello, I include the resulting file checkout.js in checkout.liqiud and it still doesn’t work. It shows “Uncaught ReferenceError: $checkout is not defined”. Could you please help me. Thank you!