php - Display custom attributes before WooCommerce upsells ( linked products) -


i manage display custom attributes shown after linked products how can make them appear before?

on left: have, right desired result

thanks enter image description here

if woocommerce template content-single-product.php see that:

/**  * woocommerce_after_single_product_summary hook.  *  * @hooked woocommerce_output_product_data_tabs - 10  * @hooked woocommerce_upsell_display - 15  * @hooked woocommerce_output_related_products - 20  */ do_action( 'woocommerce_after_single_product_summary' ); 

that means in woocommerce_after_single_product_summary hook, following displayed:

  1. first (with priority of 10) product tabs,
  2. then (with priority of 15) upsells,
  3. and finish (with priority of 20) related products.

so if want display custom code between product tabs , upsells, need use custom function hooked in woocommerce_after_single_product_summary action hook priority between 11 14.

you can way:

add_action('woocommerce_after_single_product_summary', 'custom_code_after_single_product_summary', 12 ); function custom_code_after_single_product_summary() {     global $product;      // set here post "meta_key" custom product attribute     $meta_key1 = 'pa_when-to-use';      // code (related comment):     echo get_post_meta($product->get_id(),  $meta_key1, true); } 

code goes in function.php file of active child theme (or theme) or in plugin file.

tested , works on woocommerce 3+…


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -