Forum Replies Created
-
AuthorPosts
-
December 7, 2020 at 11:48 am in reply to: Show woocommerce product commission in the shop and product page #7101
brandsload
ParticipantWell, I beleive you have to consider it, however, I did some researches and I did it, here is how you can do it
The product commission is stored in a woocommerce product custom field called “wpam_woo_product_specific_commission”
To display this field value in the products loop in shop and archive pages you need to add this function to your child theme functions.php
—–
add_action( ‘woocommerce_after_shop_loop_item_title’, ‘wpam_woo_product_specific_commission’, 35 );function wpam_woo_product_specific_commission() {
global $post;
if ( is_home() || is_shop() || is_product_category() || is_product_tag() ) {
echo ‘<span class=”woocommerce-breadcrumb”>’;
echo “Commission ” . get_post_meta( $post->ID, ‘wpam_woo_product_specific_commission’, true ) . ” $ “;
echo ‘</span>’;
}
}
—–To display the commission in the product page you need to add this code to the end of the price.php file in the woocommerce templates folder under single-product (woocommerce/templates/single-product/price.php)
—–
<?php
echo “Commission ” . get_post_meta( get_the_ID(), ‘wpam_woo_product_specific_commission’, true ) . ” $ “;
?>
—–Finally, as you edited one of the woocommerce core files, you may need to use this tool “WordPress child plugin tool” to avoid losing the modifications you made when woocommerce update
https://github.com/ThomasDepole/wordpress-child-plugin-toolHope this help
Thanks
-
AuthorPosts