Shipping Integration API
Register a Shipping method
Similar to the payment method any shipping method that is enabled for a store in the system configuration will be listed in the shipping step.
This only makes sense for shipping methods that do not need to collect any information from the customer.
If your shipping method requires additional customer input, you may need to develop a custom shipping integration that handles the necessary user interaction and data collection.
Layout XML
To display content when the shipping method is selected, a block for the shipping method needs to be declared as a child of the checkout.shipping.methods
block in the layout/hyva_checkout_components.xml
file.
For example:
<referenceBlock name="checkout.shipping.methods">
<block name="checkout.shipping.method.custom-shipping"
as="carrierCode_methodCode"
template="Hyva_Checkout::component/shipping/method/custom-shipping.phtml"/>
</referenceBlock>
The block alias (as="..."
) has to start with the carrier code followed by an underscore then the method code.
The name of the shipping block in layout XML and the template name are not required to follow a specific convention, but we suggest you follow the example above.
If you would like the template to become a magewire component, then you can do so by simply adding the magewire argument like you would elsewhere:
<referenceBlock name="checkout.shipping.methods">
<block name="checkout.shipping.method.custom-shipping"
as="carrierCode_methodCode"
template="Hyva_Checkout::component/shipping/method/custom-shipping.phtml">
<arguments>
<argument name="magewire" xsi:type="object">
Hyva\Checkout\Magewire\Checkout\Shipping\CustomShipping
</argument>
</arguments>
</block>
</referenceBlock>