Hi @wolphitdepartment,
You may please use the code snippet here to develop a similar work around. Hope it helps.
Thank you for your response. Could you please provide further instructions on how I can implement this? Thanks a lot.
I made a public function at wt-woocommerce-sequential-order-numbers/includes/class-wt-advanced-order-number.php and entered this code that you provided:
public function find_order_by_order_number( $order_number ) {
$args = array(
'post_type' => 'shop_order',
'post_status' => 'any',
'meta_query' => array(
array(
'key' => '_order_number',
'value' => $order_number, //here you pass the Order Number
'compare' => '=',
)
)
);
$query = new WP_Query( $args );
if ( !empty( $query->posts ) )
{
$order_id = $query->posts[ 0 ]->ID;
}
else
{
$order_id = $order_number;
}
return $order_id;
}
and then added this code on the payment gateway private function get_order_id [the first code snippet I provided on this thread]
elseif ( class_exists( 'Wt_Advanced_Order_Number' ) ) {
global $wt_advanced_order_number;
$order_id = $wt_advanced_order_number->find_order_by_order_number( $order_number );
if ( 0 === $order_id ) {
$order_id = $order_number;
}
}
`
Everything is fine except for the part where payment is completed and will redirect already to the Thank You page. This is the error that I am getting:
<blockquote>
Fatal error: Uncaught Error: Call to a member function find_order_by_order_number() on null in /var/www/mydomain.com/wp-content/plugins/iPay88 for Woocommerce v1.1/includes/class-wc-gateway-ipay88.php:873 Stack trace: #0 /var/www/mydomain.com/wp-content/plugins/iPay88 for Woocommerce v1.1/includes/class-wc-gateway-ipay88.php(610): WC_Gateway_iPay88->get_order_id() #1 /var/www/mydomain.com/wp-content/plugins/iPay88 for Woocommerce v1.1/includes/class-wc-gateway-ipay88.php(660): WC_Gateway_iPay88->validate_response() #2 /var/www/mydomain.com/wp-includes/class-wp-hook.php(292): WC_Gateway_iPay88->check_status_response_ipay88() #3 /var/www/mydomain.com/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters() #4 /var/www/mydomain.com/wp-includes/plugin.php(484): WP_Hook->do_action() #5 /var/www/mydomain.com/wp-content/plugins/woocommerce/includes/class-wc-api.php(161): do_action() #6 /var/www/mydomain.com/wp-includes/class-wp-hook.php(292): WC_API->handle_api_requests() #7 /v in /var/www/mydomain.com/wp-content/plugins/iPay88 for Woocommerce v1.1/includes/class-wc-gateway-ipay88.php on line 873
Your input is highly appreciated!
-
This reply was modified 4 years, 11 months ago by
wolphitdepartment. Reason: code closing tag error
Hi @wolphitdepartment,
Please try replacing the elseif code with below code:
elseif ( class_exists( 'Wt_Advanced_Order_Number' ) ){
$args = array(
'post_type' => 'shop_order',
'post_status' => 'any',
'meta_query' => array(
array(
'key' => '_order_number',
'value' => $order_number, //here you pass the Order Number
'compare' => '=',
)
)
);
$query = new WP_Query( $args );
if ( !empty( $query->posts ) )
{
$order_id = $query->posts[ 0 ]->ID;
}
}
Thank you so much! It’s working perfectly!
Hi @wolphitdepartment,
Thanks for the follow-up and glad to know that the solution provided worked for you.
If you like the plugin, please leave a review here.
Hi
I facing the same issues , may i know where I should add this file ?
elseif ( class_exists( 'Wt_Advanced_Order_Number' ) ){
$args = array(
'post_type' => 'shop_order',
'post_status' => 'any',
'meta_query' => array(
array(
'key' => '_order_number',
'value' => $order_number, //here you pass the Order Number
'compare' => '=',
)
)
);
$query = new WP_Query( $args );
if ( !empty( $query->posts ) )
{
$order_id = $query->posts[ 0 ]->ID;
}
}
Kindly advice , thanks
-
This reply was modified 4 years, 8 months ago by
TAN.