How To Remove Product Name From Breadcrumbs in Woocommerce

How To Remove Product Name From Breadcrumbs in Woocommerce

If you need to remove last element from breadcrumbs, you must:1. In the folder with your theme, create a folders "woocommerce/global" wp-content/themes/your-theme/woocommerce/global 2. Then copy ffrom Woocommerce plugin (or just create) file "breadcrumbs.php" wp-content/themes/your-theme/woocommerce/global/breadcrumbs.php 3. Replace (paste) the next code in breadcrumbs.php: <?php if ( ! defined( 'ABSPATH' ) ) { exit; } if ( ! empty( $breadcrumb ) ) { echo $wrap_before; foreach ( $breadcrumb as $key => $crumb ) { echo $before; if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) { echo '<a href="' . esc_url( $crumb[1] ) . '">' . esc_html( $crumb[0] ) . '</a>'; } else { if(!is_singular()){ echo esc_html( $crumb[0] ); ...
Read More

Woocommerce: Get All Shipping Methods in Admin With Custom Titles and Instance ID

You can foun many code snippets to get list of all available shipping methods based on order or cart object.But if you need to get this list in admin area for some purpose in your plugin, etc. you can use this code snippet: $delivery_zones = WC_Shipping_Zones::get_zones(); foreach ((array) $delivery_zones as $key => $the_zone) { echo "<b>" . $the_zone['zone_name'] . "</b><br>"; foreach ($the_zone['shipping_methods'] as $value) { //print_r($value); echo $value->title . " ( " . $value->method_title . " - " . $value->cost . ")" . $value->id . ":" . $value->instance_id; } echo "<br>"; } The key here is getting methods with already initialized instance_id. This code also can be found on Stackoverflow. ...
Read More

How To Sort Products in Woocommerce Catalog both by Stock Status and Popularity

The post_clauses filter in WooCommerce allows you to modify the SQL clauses that are used to retrieve products from the database. You can use this filter to sort products by popularity and stock status in the WooCommerce catalog by adding the following code to your theme's functions.php file or a custom plugin: <?php /** * Order product collections by stock status, instock products first. */ class iWC_Orderby_Stock_Status { public function __construct() { // Check if WooCommerce is active if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000); } } public function order_by_stock_status($posts_clauses) { global $wpdb; // only change query on WooCommerce loops ...
Read More

How to resolve “PHP Notice: Undefined index: width in class-wc-regenerate-images.php on line 276”

After recent Woocommerce update on some website the PHP notice is appeared, like: PHP Notice: Undefined index: width in plugins/woocommerce/includes/class-wc-regenerate-images.php on line 276 PHP Notice: Undefined index: height in plugins/woocommerce/includes/class-wc-regenerate-images.php on line 277 This problem is caused by SVG-files mostly. So when in Woocommerce fucntion such mime type is checked some SVG images can has such structure, which call the php notice: Array ( [filesize] => 4427 ) How to fix Add this to you functions.php or other included to theme file: /** * Disable Woocommerce resize for SVG images. */ add_filter( 'wp_get_attachment_image_src', 'fix_wp_get_attachment_image_svg', 10, 4 ); function fix_wp_get_attachment_image_svg($image, $attachment_id, $size, $icon) { // if Woocommerce enabled if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { $attachment = get_post($attachment_id); $mime_type = $attachment->post_mime_type; // The attachment mime_type if($mime_type == 'image/svg+xml') { return false; ...
Read More

How to make email notifications of new product for Woocommerce

Sometimes if you're selling some products which are highly demand by customers such feature like notifications to email regarding new items listed for sale in your Woocommerce store can be very useful. This an easy way to make these notifications available for subscribers: Go to https://feedburner.google.com and add the RSS feed for your products (you should have Google account registered). The correct feed for your domain will be like: https://yourdomain.com/feed/?post_type=product Also you can previously check feed for your woocommerce shop online here:https://validator.w3.org/feed/ On the next screen you can set up the Title and feed name. It's up to your opinion. Now your feed is ready. Let's add subscribe form to get possibility for customers sign up to receive your Woocommerce store new listings updates. Go to the next screen, then one else and press menu point "Publicize". Press "activate" at the bottom of screen and then you'll be able to grab or HTML-code of subscription form, or HTML-code of link to sign up for emails. The code of form...
Read More