Co-written by @ralucastn and @nielslange
This is chapter 5 of 5 in the series Getting to Know Woo: A Series on the Cart and Checkout Blocks
In the previous posts, we’ve looked at extensibility on the front end side, focusing on adding new content, modifying existing content, and extending payment methods. However, you may sometimes need to modify behavior on the server side. In this final post of the series, we will look at action and filter hooks available in the Cart and Checkout blocks.
Extensibility on the Server Side (Hooks)
There are also some PHP action and filter hooks provided for extending various aspects of checkout behavior on the server. Keep in mind that itโs generally preferable to use extension interfaces like the IntegrationRegistry instead of actions and filters, as they provide a more stable way to integrate. However, these actions and filters still allow for some more flexibility in complex integrations.
Actions
- woocommerce_add_to_cart
- woocommerce_applied_coupon
- woocommerce_blocks_cart_enqueue_data
- woocommerce_blocks_checkout_enqueue_data
- woocommerce_blocks_checkout_order_processed (deprecated)
- woocommerce_blocks_checkout_update_order_from_request (deprecated)
- woocommerce_blocks_checkout_update_order_meta (deprecated)
- woocommerce_blocks_enqueue_cart_block_scripts_after
- woocommerce_blocks_enqueue_cart_block_scripts_before
- woocommerce_blocks_enqueue_checkout_block_scripts_after
- woocommerce_blocks_enqueue_checkout_block_scripts_before
- woocommerce_blocks_loaded
- woocommerce_blocks_{$this->registry_identifier}_registration
- woocommerce_check_cart_items
- woocommerce_created_customer
- woocommerce_register_post
- woocommerce_rest_checkout_process_payment_with_context
- woocommerce_store_api_checkout_order_processed
- woocommerce_store_api_checkout_update_order_from_request
- woocommerce_store_api_checkout_update_order_meta
- wooocommerce_store_api_validate_add_to_cart
- wooocommerce_store_api_validate_cart_item
Please note that the list might change as we are continuously working on graduating or removing experimental features.
Filters
- __experimental_woocommerce_blocks_add_data_attributes_to_block
- __experimental_woocommerce_blocks_add_data_attributes_to_namespace
- __experimental_woocommerce_blocks_payment_gateway_features_list
- wc_stripe_allow_prepaid_card (deprecated)
- wc_stripe_display_save_payment_method_checkbox (deprecated)
- wc_stripe_payment_request_button_locale (deprecated)
- woocommerce_add_cart_item
- woocommerce_add_cart_item_data
- woocommerce_add_to_cart_sold_individually_quantity
- woocommerce_add_to_cart_validation
- woocommerce_adjust_non_base_location_prices
- woocommerce_apply_individual_use_coupon
- woocommerce_apply_with_individual_use_coupon
- woocommerce_blocks_product_grid_is_cacheable
- woocommerce_blocks_product_grid_item_html
- woocommerce_blocks_register_script_dependencies
- woocommerce_cart_contents_changed
- woocommerce_ga_disable_tracking
- woocommerce_get_item_data
- woocommerce_new_customer_data
- woocommerce_registration_errors
- woocommerce_shared_settings
- woocommerce_shipping_package_name
- woocommerce_store_api_disable_nonce_check
- woocommerce_store_api_product_quantity_limit
- woocommerce_variation_option_name
Please note that the list might change as we are continuously working on graduating or removing experimental features.
For more details, please head to our GitHub documentation:
Thanks for joining us
We hope you enjoyed our 5 part series on getting to know the Cart and Checkout blocks a little better. You can find a link to all the posts in this series in our original announcement post.
If you have any questions during the integration process, our recommendation is to reach out on our GitHub Discussions section Q&A โ Extension Integrations and Customizations or in the Community Slack #woocommerce-blocks-and-block-themes channel.
Leave a Reply