Germanized for WooCommerce, by Vendidero
Guide to using Germanized for WooCommerce with Advanced Dynamic Pricing: learn about known limitations, template and tax nuances, and how to keep prices and legal information consistent.
Add provided code to functions.php and update Settings.
Calculation option “Use prices modified by other plugins” must be ON.
System option “Suppress other pricing plugins in frontend” must be OFF.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
// One Item discount fix add_action( 'wdp_before_apply_to_wc_cart', function ( $wdp_cart, $wc_cart ) { remove_filter( 'woocommerce_cart_item_price', 'wc_gzd_cart_product_unit_price', 0 ); add_filter( 'woocommerce_cart_item_price', 'wc_gzd_cart_product_unit_price', 100, 3 ); }, 10, 2 ); // fix product price after purchase it add_action( 'woocommerce_gzd_before_get_unit_price', function($product){ $product->recalculate_unit_price(); }, 10, 1 ); add_filter( 'woocommerce_gzd_get_unit_price_raw', function ( $unit_price, $product ) { /** * @var $product WC_GZD_Product */ if ( isset( $product->wdp_original_price ) ) { if ( $product->wdp_original_price > $product->get_price( '' ) ) { $product->recalculate_unit_price( array( 'price' => $product->get_price( '' ) ) ); $unit_price = $product->unit_price; } } else { if ( ! is_cart() && ! is_checkout() ) { if ( $product->is_on_sale() ) { $product->recalculate_unit_price( array( 'price' => $product->get_sale_price() ) ); $unit_price = $product->unit_price; } } } return $unit_price; }, 10, 2 ); add_filter( 'woocommerce_cart_item_product', function ( $product, $cart_item, $cart_item_key ) { /** * @var WC_Product $product * */ if ( isset( $cart_item['wdp_original_price'] ) ) { if ( isset( $product->gzd_product ) ) { $product->gzd_product->wdp_original_price = $cart_item['wdp_original_price']; $product->gzd_product->get_wc_product()->set_price($product->get_price( '' )); } } return $product; }, 10, 3 ); add_filter( 'woocommerce_gzd_order_item_unit_price', function ( $price_html, $gzd_product, $item, $order ) { if ( isset($item->legacy_values['data']) ) { $gzd_product->get_wc_product()->set_price($item->legacy_values['data']->get_price('')); $price_html = $gzd_product->get_unit_html( false ); } return $price_html; }, 10, 4 ); |