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
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:
- first (with priority of 10) product tabs,
- then (with priority of 15) upsells,
- 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
Post a Comment