Adding custom content after the Add to Cart button

The Add to Cart button is loaded within the woocommerce_after_single_product_summary action. It will be the last element in the product summary section unless we have meta information for it. So, we implemented this hook with a callback function called wpccp_woocommerce_single_product_summary_data. Inside this function, we just returned the content we wanted to display. The important thing is the use of the priority parameters for the hook. In this case, we set it to 70 to make it display at the end of the summary section. Let's take a look at the following comments section, which has been extracted from the content-single-product.php template:

 * @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_excerpt – 20
* @hooked woocommerce_template_single_price - 30
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50

This section shows action hooks executed within the woocommerce_single_product_summary hook. Each hook displays specific data for the product and has a default priority value. So, the data on the product page is loaded based on this priority.

The preceding comment has been modified from the original template to include woocommerce_template_single_price as 30, as it incorrectly states 10 on the original template comments.

The priority of the last element is 60, so we added 70 as the priority to display the content at the end.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.55.193