thiet-ke-noi-that/wp-content/themes/flatsome/inc/woocommerce/structure-wc-single-product-custom.php
nguyen dung 39b8cb3612 init
2022-02-18 16:43:41 +07:00

22 lines
727 B
PHP

<?php
/**
* Generate product structured data at later point.
* (hook woocommerce_single_product_summary is not always available)
*/
function flatsome_single_product_custom_structured_data() {
if ( ! class_exists( 'WC_Structured_Data' ) ) {
return;
}
$structured_data = WC()->structured_data;
if ( ! is_object( $structured_data ) || ! is_a( $structured_data, 'WC_Structured_Data' ) ) {
return;
}
remove_action( 'woocommerce_single_product_summary', [ $structured_data, 'generate_product_data' ], 60 );
add_action( 'woocommerce_after_single_product', [ $structured_data, 'generate_product_data' ], 60 );
}
add_action( 'flatsome_before_single_product_custom', 'flatsome_single_product_custom_structured_data' );