Skip to content

Commit

Permalink
Make sure to only adjust checkbox position for Elementor Pro in case …
Browse files Browse the repository at this point in the history
…the checkout shortcode is missing from the current post. PayPal Payments tracking carrier naming.
  • Loading branch information
dennisnissle committed Dec 7, 2023
1 parent d06ff57 commit baaa2b7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion includes/admin/class-wc-gzd-admin-setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public function wc_gzd_setup_provider_save() {
$provider->activate();
update_option( '_wc_gzd_setup_shipping_provider_activated', 'yes' );
} else {
$provider->deactivate();
$provider->deactivate();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ function() {
}

/**
* Move checkboxes right before order summary
* Move checkboxes right before order summary in case the current
* checkout is built with Elementor Pro.
*/
if ( has_action( 'woocommerce_review_order_after_payment', 'woocommerce_gzd_template_render_checkout_checkboxes' ) ) {
$has_removed = remove_action( 'woocommerce_review_order_after_payment', 'woocommerce_gzd_template_render_checkout_checkboxes', 10 );
if ( ! wc_gzd_post_content_has_shortcode( 'woocommerce_checkout' ) ) {
if ( has_action( 'woocommerce_review_order_after_payment', 'woocommerce_gzd_template_render_checkout_checkboxes' ) ) {
$has_removed = remove_action( 'woocommerce_review_order_after_payment', 'woocommerce_gzd_template_render_checkout_checkboxes', 10 );

if ( $has_removed ) {
add_action( 'woocommerce_checkout_order_review', 'woocommerce_gzd_template_render_checkout_checkboxes', 19 );
if ( $has_removed ) {
add_action( 'woocommerce_checkout_order_review', 'woocommerce_gzd_template_render_checkout_checkboxes', 19 );
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,24 @@ function() {
);

add_filter(
'woocommerce_paypal_payments_default_gzd_carrier',
function( $carrier, $provider ) {
if ( strstr( $provider, 'dpd' ) ) {
$carrier = 'DPD';
} elseif ( strstr( $provider, 'gls' ) ) {
$carrier = 'GLS';
} elseif ( strstr( $provider, 'hermes' ) ) {
$carrier = 'HERMES';
} elseif ( strstr( $provider, 'ups' ) ) {
$carrier = 'UPS';
'woocommerce_paypal_payments_tracking_data_before_update',
function( $shipment_data ) {
if ( isset( $shipment_data['carrier'] ) ) {
if ( strstr( $shipment_data['carrier'], 'dpd' ) ) {
$shipment_data['carrier'] = 'DPD';
} elseif ( strstr( $shipment_data['carrier'], 'gls' ) ) {
$shipment_data['carrier'] = 'GLS';
} elseif ( strstr( $shipment_data['carrier'], 'hermes' ) ) {
$shipment_data['carrier'] = 'HERMES';
} elseif ( strstr( $shipment_data['carrier'], 'ups' ) ) {
$shipment_data['carrier'] = 'UPS';
}
}

return $carrier;
return $shipment_data;
},
10,
2
1
);
}

Expand Down
10 changes: 10 additions & 0 deletions includes/wc-gzd-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,16 @@ function wc_gzd_update_page_content( $page_id, $content, $append = true ) {
}
}

function wc_gzd_post_content_has_shortcode( $tag = '' ) {
if ( function_exists( 'wc_post_content_has_shortcode' ) ) {
return wc_post_content_has_shortcode( $tag );
} else {
global $post;

return is_singular() && is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, $tag );
}
}

function wc_gzd_content_has_shortcode( $content, $shortcode ) {
global $shortcode_tags;

Expand Down

0 comments on commit baaa2b7

Please sign in to comment.