I put product status and other info in short description field on wp all import for all products like this:
URL: <a href="https://www.msi.com/Graphics-card/GeForce-GTX-1650-GAMING-4G/Specification" target="_blank" rel="noopener noreferrer">Производител линк</a> <i class="fa fa-check" aria-hidden="true"></i> Наличен <i class="fa fa-truck" aria-hidden="true"></i> Доставка 1-3 дни
I want if product category is Videocards to change product status and icon to “call” insted of “avaliable” like this:
URL: <a href="https://www.msi.com/Graphics-card/GeForce-GTX-1650-GAMING-4G/Specification" target="_blank" rel="noopener noreferrer">Производител линк</a> <i class="fa fa-volume-control-phone" aria-hidden="true"></i> Обадете се <i class="fa fa-truck" aria-hidden="true"></i> Доставка 1-3 дни
Any way to do this with custom function in wp all import or in function.php file of my active child theme?
Advertisement
Answer
You can use the following code:
<?php add_filter( 'woocommerce_short_description', 'ywp_custom_single_excerpt' ); function ywp_custom_single_excerpt( $description ) { global $product; $categories = array( 'videocards' ); // You can add more categories if( has_term( $categories, 'product_cat', $product ) ) { return str_replace( '<i class="fa fa-check" aria-hidden="true"></i> Наличен ', '<i class="fa fa-volume-control-phone" aria-hidden="true"></i> Обадете се ', $description ); } return $description; }
Code goes in the functions.php
file of your active theme/child theme. Tested and works.