Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @jnser,

    the mentioned checkout hooks will not work with the block checkout.

    There are two options to an HTML element to the checkout form:

    1. Open the “WP Admin -> Pages -> Checkout” page for editing, remove the checkout block and add the [woocommerce_checkout] shortcode. This will enable you to use the checkout hooks.
    2. Open the “WP Admin -> Pages -> Checkout” page for editing, add a paragraph/image/shortcode block before/after the checkout block, or after any of the checkout inner blocks in order to display your HTML element.

    Hi Diana,

    Thanks for your reply. I’m building a plugin that updates the checkout block, does that mean it wont ever work on clients using WooCommerce 8.7.0 checkout? Unless I require them to customise their own checkout.

    I have the same issue for woocommerce_widget_shopping_cart_total

    If your plugin needs to add an HTML element after one of the checkout inner blocks, you should write a block plugin where the block.json file should contain the:

    • “parent”: [ “woocommerce/checkout-shipping-methods-block” ] line. Change the “checkout-shipping-methods-block” string with the inner block of your choice
    • “attributes”: { “lock”: { “type” : “object”, “default”: { “remove”: true, “move”: true } } } line. This will ensure that your block is automatically loaded as an part of one of the checkout inner blocks and the user cannot remove it in the editor, unless it deactivates your plugin.

    See the src/js/shipping-workshop-block/block.json file in the Shipping Workshop Block project, used by the WooCommerce team as an example for an addon which modifies the checkout block.

    If your plugin needs to add an HTML element before or after the checkout block, then you can look into the Block Hooks API, which will allow you to dynamically add blocks after/before another block. This will work only with WordPress 6.5.

    Thank you, @diana_burduja, for the help and input! ??

    @jnser,

    While we can’t provide support for code customization as per our support policy, we do our best to offer advice and direct you to appropriate resources.

    If you need further help, you can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there too.

    I’m going to leave it open for a bit so you and @diana_burduja can continue your discussion ??

    Please let us know if there’s anything else we can do to help or if you have any questions.

    Have a wonderful day!

    Thanks @diana_burduja, very helpful.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WooCommerce 8.7.0 : some hooks on checkout dont work’ is closed to new replies.