Skip to content

Commit

Permalink
Hook adjustment.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Oct 25, 2024
1 parent 1baf2b0 commit b9986dc
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/ShippingMethod/MethodHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,9 @@ public static function init() {
add_filter( 'woocommerce_generate_shipping_provider_method_tabs_close_html', array( __CLASS__, 'render_method_tab_content_close' ), 10, 4 );
add_filter( 'woocommerce_generate_shipping_provider_method_configuration_sets_html', array( __CLASS__, 'render_method_configuration_sets' ), 10 );

add_filter( 'woocommerce_cart_shipping_packages', array( __CLASS__, 'register_cart_items_to_pack' ) );
add_filter( 'woocommerce_shipping_methods', array( __CLASS__, 'register_shipping_methods' ) );
add_filter( 'woocommerce_hidden_order_itemmeta', array( __CLASS__, 'set_shipping_order_meta_hidden' ) );

add_filter( 'woocommerce_cart_shipping_packages', array( __CLASS__, 'register_cart_items_to_pack' ) );

add_action(
'woocommerce_before_calculate_totals1',
function ( $cart ) {
remove_filter( 'woocommerce_cart_shipping_packages', array( __CLASS__, 'register_cart_items_to_pack' ) );

add_filter(
'woocommerce_cart_shipping_packages',
function ( $package ) use ( $cart ) {
$package = self::register_cart_items_to_pack( $package, $cart );

return $package;
}
);
}
);
}

public static function set_shipping_order_meta_hidden( $meta ) {
Expand Down Expand Up @@ -85,8 +68,6 @@ public static function register_cart_items_to_pack( $cart_contents ) {
return $cart_contents;
}

$cart = WC()->cart;

foreach ( $cart_contents as $index => $content ) {
$package_data = array(
'total' => 0.0,
Expand Down Expand Up @@ -157,6 +138,7 @@ public static function register_cart_items_to_pack( $cart_contents ) {
* no item total amount (incl taxes) available.
*/
if ( 0 !== $cart_contents[ $index ]['cart_subtotal'] && apply_filters( 'woocommerce_gzd_shipments_prefer_cart_totals_over_cart_item_totals', false, $cart_contents ) ) {
$cart = WC()->cart;
$total = (float) $cart->get_cart_contents_total();

if ( $cart->display_prices_including_tax() ) {
Expand Down

0 comments on commit b9986dc

Please sign in to comment.