At first, we can see the hook used in woocommerce product page.
Every hook displays one product detail. You will notice that each hook has a number associated to it. This number sets the priority of the hook and determines the execution order of the hook. In this case, the higher the number, the lower would be the priority of the execution. For example, the execution order of the ‘woocommerce_single_product_summary’ would be product title, price, excerpt, add-to-cart, meta, and sharing links
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
Now in order to change the order of the items, just change the associated priority and WordPress will change the display order. For this, just remove the hook first and then re-add the hook with the revised priority. Check out the following code snippet for implementation of this process:
/** excerpt position change **/
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 31 );
Create and Show Custom Fields
Now in order to display the custom data on the product summary page, I will use a function that hooks the fields to a WooCommerce action (with the desired priority). In the following code example, I will display custom fields after product excerpt but before add-to-cart:
function ka_add_custom_fields()
{
echo 'CUSTOMIZE CONTENT'.get_post_meta(get_the_ID(), "CUSTOMIZE CONTENT", true);
echo 'CUSTOMIZEFIELD'.get_field(“CUSTOMIZEFIELD”);
}
add_action( 'woocommerce_single_product_summary', 'ka_add_custom_fields', 21 );