In the plugin settings we set default custom order status as “to be confirmed by operator”. For new order the plugin correctly assigns this default status and sends user notification email. After confirmation the order is being processed. While being processed we change its status several times, like “packaging”, “shipped”, “received” etc. The problem is, if the user reloads the order thank-you page (/checkout/order-received/1234//?key=wc_order_…) at any moment, the plugin is triggered as if it was a new order and reverts its status to default, regardless of current progress. Sometimes the thank-you page remains open on user’s device and reloads after browser restart (or waking up from sleep), even after several days.
I guess, that’s because you use ‘woocommerce_thankyou’ action hook for setting default status. This action is fired every time the thank-you page loads.
This causes much confusion, users receive duplicate notifications for orders they placed several days ago, or even already picked up.
Each order should be processed only once. Maybe, you could somehow flag the order after setting the default status for the first time and check the flag on every event, preventing subsequent status reset.
Thank you very much, I hoope you could resolve this ASAP.
]]>function ax_wc_fix_gzd_thankyoupage_taxes($tax_array, $cart, $include_shipping_taxes){
if ( is_order_received_page() ) {
global $wp;
$tax_array = array();
// Get the order. Following lines are present in order_received() in includes/shortcodes/class-wc-shortcode-checkout.php file
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) );
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );
if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) {
$order = false;
}
}
if ( $order instanceof WC_Order ) {
$taxes = $order->get_tax_totals();
foreach ( $taxes as $code => $tax ) {
$rate = wc_gzd_get_tax_rate( $tax->rate_id );
if ( ! $rate ) {
continue;
}
if ( ! empty( $rate ) && isset( $rate->tax_rate ) ) {
$tax->rate = $rate->tax_rate;
}
if ( ! isset( $tax_array[ $tax->rate ] ) ) {
$tax_array[ $tax->rate ] = array(
'tax' => $tax,
'amount' => $tax->amount,
'contains' => array( $tax ),
);
} else {
array_push( $tax_array[ $tax->rate ]['contains'], $tax );
$tax_array[ $tax->rate ]['amount'] += $tax->amount;
}
}
}
return $tax_array;
}
}
add_filter('woocommerce_gzd_cart_taxes','ax_wc_fix_gzd_thankyoupage_taxes',10, 3);
]]>On our wordpress-installation, we are using a custom orderId (with prefix) that breaks the custom javascript code located in “duracelltomi-google-tag-manager/integration/woocommerce.php” starting from line 678.
That has been added to functions.php custom code to change orderid from (int) type “12345” to a mixed datatype “OnlineShop-12345”:
// WOOCOMMERCE: ORDER NUMBER PRE- AND SUFFIX
add_filter('woocommerce_order_number', 'change_woocommerce_order_number', 1, 2);
function change_woocommerce_order_number($order_id, $order) {
$prefix = 'Onlineshop-';
$suffix = '';
return $prefix . $order->get_id() . $suffix;
}
Browser console is showing “Uncaught ReferenceError: Onlineshop is not defined” … Here is the code rendered in frontend from GTM4WP:
<script type="text/javascript" id="gtm4wp-additional-datalayer-pushes-js-after">
/* <![CDATA[ */
// Check whether this order has been already tracked in this browser.
// Read order id already tracked from cookies or local storage.
let gtm4wp_orderid_tracked = "";
if ( !window.localStorage ) {
let gtm4wp_cookie = "; " + document.cookie;
let gtm4wp_cookie_parts = gtm4wp_cookie.split( "; gtm4wp_orderid_tracked=" );
if ( gtm4wp_cookie_parts.length == 2 ) {
gtm4wp_orderid_tracked = gtm4wp_cookie_parts.pop().split(";").shift();
}
} else {
gtm4wp_orderid_tracked = window.localStorage.getItem( "gtm4wp_orderid_tracked" );
}
// Check whether this order has been already tracked before in this browser.
let gtm4wp_order_already_tracked = false;
if ( gtm4wp_orderid_tracked && ( Onlineshop-214355 == gtm4wp_orderid_tracked ) ) {
gtm4wp_order_already_tracked = true;
}
// only push purchase action if not tracked already.
if ( !gtm4wp_order_already_tracked ) {
dataLayer.push({"event":"purchase","ecommerce":{"currency":"EUR","transaction_id":"Onlineshop-214355","affiliation":"","value":140.42,"tax":22.42,"shipping":0,"coupon":"","items":[{"item_id":"U3818","item_name":"Plom 113","sku":"113s","price":118,"stocklevel":null,"stockstatus":"instock","google_business_vertical":"retail","item_category":"Zubehoer","id":"U3818","item_brand":"Unbekannt","quantity":1}]}});
}
// Store order ID to prevent tracking this purchase again.
if ( !window.localStorage ) {
var gtm4wp_orderid_cookie_expire = new Date();
gtm4wp_orderid_cookie_expire.setTime( gtm4wp_orderid_cookie_expire.getTime() + (365*24*60*60*1000) );
var gtm4wp_orderid_cookie_expires_part = "expires=" + gtm4wp_orderid_cookie_expire.toUTCString();
document.cookie = "gtm4wp_orderid_tracked=" + Onlineshop-214355 + ";" + gtm4wp_orderid_cookie_expires_part + ";path=/";
} else {
window.localStorage.setItem( "gtm4wp_orderid_tracked", Onlineshop-214355 );
}
/* ]]> */
</script>
Fix would be, adding the orderid to quotes?
Thanks for helping with this issue!
]]>The fields are displayed on the thankyou Page only to users who have an activated account.
Users who purchase as a guest are not shown on the thank you page
What is wrong?
Thanks and regards
Yan
]]>Podrían despues de 5 segundos a hecho el pago, dispara una redirección a la thankyou page
Gracias.
]]>I’ve experimented an ERROR 500 in confirmation page when a “logged user” finish the purchase since last update 3.1.2.
This ERROR is only on “logged users”. With “new users” (first purchase) everything works fine.
(I just turned off the plugin and there is no error)
WordPress 5.7.2
Woocommerce 5.4.1
PHP 7.4.16