Skip to content

Commit

Permalink
Fix product factory usage to prevent error. Bump to 3.18.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Sep 26, 2024
1 parent 523feed commit c340d7b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion assets/js/static/add-to-cart-variation.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
};

GermanizedVariationForm.prototype.showOrHideTabs = function( self, has_product_safety_information = undefined ) {
has_product_safety_information = undefined === has_product_safety_information ? self.params.has_product_safety_information : has_product_safety_information;
has_product_safety_information = undefined === has_product_safety_information ? self.$product.hasClass( 'has-product-safety-information' ) : has_product_safety_information;

if ( has_product_safety_information ) {
self.$product.find( '.product_safety_tab' ).show().css( 'display', 'inline-block' );
Expand Down
2 changes: 1 addition & 1 deletion includes/wc-gzd-product-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function wc_gzd_get_gzd_product( $product ) {
return $product;
}

if ( ! $product ) {
if ( ! is_a( $product, 'WC_Product' ) ) {
return false;
}

Expand Down
13 changes: 13 additions & 0 deletions includes/wc-gzd-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ function woocommerce_gzd_template_product_review_authenticity_status( $comment )
}
}

if ( ! function_exists( 'woocommerce_gzd_template_product_classes' ) ) {

function woocommerce_gzd_template_product_classes( $classes, $product ) {
if ( $gzd_product = wc_gzd_get_gzd_product( $product ) ) {
if ( $gzd_product->has_product_safety_information() ) {
$classes[] = 'has-product-safety-information';
}
}

return $classes;
}
}

if ( ! function_exists( 'woocommerce_gzd_template_register_product_tabs' ) ) {

function woocommerce_gzd_template_register_product_tabs( $tabs ) {
Expand Down
1 change: 1 addition & 0 deletions includes/wc-gzd-template-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function woocommerce_gzd_register_checkout_total_taxes() {
* Product safety tab
*/
add_filter( 'woocommerce_product_tabs', 'woocommerce_gzd_template_register_product_tabs', 20 );
add_filter( 'woocommerce_post_class', 'woocommerce_gzd_template_product_classes', 10, 2 );

// Small enterprises
if ( wc_gzd_is_small_business() ) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "woocommerce-germanized",
"title": "Germanized for WooCommerce",
"version": "3.18.0",
"version": "3.18.1",
"homepage": "https://vendidero.de/woocommerce-germanized",
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requires at least: 5.4
Tested up to: 6.6
WC requires at least: 3.9
WC tested up to: 9.2
Stable tag: 3.18.0
Stable tag: 3.18.1
Requires PHP: 5.6
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -205,6 +205,9 @@ Bug reports may be filed via our [GitHub repository](https://github.com/vendider
6. Edit pdf documents (Pro)

== Changelog ==
= 3.18.1 =
* Fix: Product map caching issue

= 3.18.0 =
* New: Compliance with new GPSR regulation
* Improvement: Refactored shipments integration settings UI
Expand Down
21 changes: 5 additions & 16 deletions woocommerce-germanized.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Germanized for WooCommerce
* Plugin URI: https://www.vendidero.de/woocommerce-germanized
* Description: Germanized for WooCommerce extends WooCommerce to become a legally compliant store in the german market.
* Version: 3.18.0
* Version: 3.18.1
* Author: vendidero
* Author URI: https://vendidero.de
* Requires at least: 5.4
Expand Down Expand Up @@ -69,7 +69,7 @@ final class WooCommerce_Germanized {
*
* @var string
*/
public $version = '3.18.0';
public $version = '3.18.1';

/**
* @var WooCommerce_Germanized $instance of the plugin
Expand Down Expand Up @@ -1208,23 +1208,12 @@ public function get_variation_script_params() {
}
}

$has_product_safety_information = false;

if ( is_singular( 'product' ) ) {
global $product;

if ( $product && ( $gzd_product = wc_gzd_get_gzd_product( $product ) ) ) {
$has_product_safety_information = $gzd_product->has_product_safety_information();
}
}

return apply_filters(
'woocommerce_gzd_add_to_cart_variation_params',
array(
'wrapper' => '.product',
'has_safety_information' => $has_product_safety_information,
'price_selector' => $price_selector,
'replace_price' => true,
'wrapper' => '.product',
'price_selector' => $price_selector,
'replace_price' => true,
)
);
}
Expand Down

0 comments on commit c340d7b

Please sign in to comment.