How to use Custom Field to display product brief description in shop page with Woocommerce?

The brief description of a WooCommerce product is store as post_excerpt, to programmatically add some text, you need to hook through product excerpt. add_filter(‘get_the_excerpt’, ‘custom_excerpt’); function exc($custom_excerpt) { global $post; if($post->post_type == ‘product’){ $custom_add = __(‘This product is unavailable for some countries, please, read our terms & conditions to know more about this.’, ‘folkstone’); return … Read more

Apply a custom WooCommerce order status based on user role

You can use folloeing code to register you custm status and change it when specific user ordered the product: function register_awaiting_shipment_order_status() { register_post_status( ‘wc-pendingwholesale’, array( ‘label’ => ‘Awaiting shipment’, ‘public’ => true, ‘exclude_from_search’ => false, ‘show_in_admin_all_list’ => true, ‘show_in_admin_status_list’ => true, ‘label_count’ => _n_noop( ‘Awaiting shipment <span class=”count”>(%s)</span>’, ‘Awaiting shipment <span class=”count”>(%s)</span>’ ), ) ); … Read more

Woocommerce Remove Tax by Product Type

After many headaches and trials and errors, instead of trying to recalculate the taxes, I just altered the taxes. I changed my foreach loop in the second function to the following: if(‘metal’===get_post_meta($item[‘product_id’], ‘_product_type’, 1)): $cart->taxes[1] -= $item[‘line_tax’]; $cart->tax_total -= $item[‘line_tax’]; $item[‘line_tax’] = 0; $item[‘line_subtotal_tax’] = 0; $item[‘line_tax_data’] = []; $cart->cart_contents[$key] = $item; endif; Now it … Read more

Display data when category is empty

You have used woocommerce_after_shop_loop action hook which is within the following condition: <?php if ( have_posts() ) : ?> You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category. UPDATE: You can add condition to your … Read more

Remove Visual Editor and P tags from WooCommerce Taxonomy Descriptions [closed]

Hope, The following code solve your problem. Add this in functions.php $tags = $_GET[‘taxonomy’]; $taxonomy_name = array(‘product_tag’,’product_cat’); if (in_array($tags, $taxonomy_name)) { add_action(“{$tags}_edit_form_fields”, ‘form_fields’, 10, 2); } function form_fields($term, $taxonomy){ ?> <tr valign=”top”> <th scope=”row”>Description</th> <td> <?php wp_editor(html_entity_decode($term->description), ‘description’, array(‘media_buttons’ => false,’quicktags’ => false)); ?> <style> .js .tmce-active .wp-editor-area{ color:black !important; } </style> <script> jQuery(window).ready(function(){ jQuery(‘label[for=description]’).parent().parent().remove(); … Read more