HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/insiders/wp-load/wp-content/plugins/gutenmate/lib/woocommerce.php
<?php

add_action( 'init', 'gtm_init_woocommerce' );

function gtm_init_woocommerce() {
	if ( get_theme_support( 'gutenmate-woocommerce' ) ) {
		add_filter( 'woocommerce_get_breadcrumb', 'gtm_woocommerce_get_breadcrumb', 10, 2 );
	}
}

function gtm_woocommerce_get_breadcrumb( $crumbs, $breadcrumb ) {
	$shop_page_id = wc_get_page_id( 'shop' ); // Requesting the shop page ID
	if ( $shop_page_id > 0 && ! is_shop() && ( is_product_taxonomy() || is_product() ) ) { // We check the correctness of the received ID and that the current page is not a store page and that the page is a product page or a product category
		$new_breadcrumb = [
			//_x( 'Shop', 'breadcrumb', 'woocommerce' ), // A string for adding your own shop name. To use uncomment it but comment out the following
			get_the_title( wc_get_page_id( 'shop' ) ), // Requesting the name of the shop page
			get_permalink( wc_get_page_id( 'shop' ) ), // Requesting the URL of the shop page
		];
		array_splice( $crumbs, 1, 0, [$new_breadcrumb] ); // Add a new item to the breadcrumbs after the "Home" item
	}
	
	return $crumbs;
}