Skip to content

Commit

Permalink
Register structured product data (GTIN, MPN). Patch Elementor Pro com…
Browse files Browse the repository at this point in the history
…patibility as the elementor-pro stylesheet doesn't exist in newest elementor version.
  • Loading branch information
dennisnissle committed Nov 13, 2024
1 parent 095b81c commit ef65432
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function ( $element ) {
'elementor/frontend/after_enqueue_styles',
function () {
wp_add_inline_style(
'elementor-pro',
'elementor-frontend',
'
.elementor-widget-woocommerce-checkout-page .woocommerce table.woocommerce-checkout-review-order-table {
margin: var(--sections-margin, 24px 0 24px 0);
Expand Down
16 changes: 14 additions & 2 deletions woocommerce-germanized.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public function init() {
add_action( 'wp_print_footer_scripts', array( $this, 'localize_scripts' ), 5 );

add_filter( 'woocommerce_locate_core_template', array( $this, 'email_templates' ), 0, 3 );
add_filter( 'woocommerce_structured_data_product', array( $this, 'add_structured_product_data' ), 10, 2 );

// Payment gateways
add_filter( 'woocommerce_payment_gateways', array( $this, 'register_gateways' ) );
Expand Down Expand Up @@ -1520,7 +1521,6 @@ public function add_emails( $mails ) {
* @return string
*/
public function email_templates( $core_file, $template, $template_base ) {

if ( ! file_exists( $template_base . $template ) && file_exists( $this->plugin_path() . '/templates/' . $template ) ) {
$core_file = $this->plugin_path() . '/templates/' . $template;
}
Expand All @@ -1539,7 +1539,6 @@ public function email_templates( $core_file, $template, $template_base ) {
}

public function register_gateways( $gateways ) {

// Do only load gateway for PHP >= 5.3 because of Namespaces
if ( version_compare( phpversion(), '5.3', '>=' ) ) {
$gateways[] = 'WC_GZD_Gateway_Direct_Debit';
Expand All @@ -1549,6 +1548,19 @@ public function register_gateways( $gateways ) {

return $gateways;
}

public function add_structured_product_data( $markup, $product ) {
if ( $gzd_product = wc_gzd_get_gzd_product( $product ) ) {
if ( $gtin = $gzd_product->get_gtin() ) {
$markup['gtin'] = $gtin;
}
if ( $mpn = $gzd_product->get_mpn() ) {
$markup['mpn'] = $mpn;
}
}

return $markup;
}
}

endif;
Expand Down

0 comments on commit ef65432

Please sign in to comment.