Skip to content

Commit

Permalink
Merge pull request #954 from payplug/SMP-3022
Browse files Browse the repository at this point in the history
SMP-3022 : Using hook to get the order id
  • Loading branch information
PPmmesquita authored Nov 29, 2024
2 parents 90c2a2a + a0c10ab commit 54186f5
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Gateway/PayplugGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public function customize_gateway_title($total_rows, $order)
*/
public function validate_payment($id = null, $save_request = true, $ipn = false)
{
global $wp;

if(!$ipn){
if (!is_wc_endpoint_url('order-received') || (empty($_GET['key']) && empty($id)) ) {
return;
Expand All @@ -289,10 +291,24 @@ public function validate_payment($id = null, $save_request = true, $ipn = false)
}

if (empty($order_id)) {
$order_id = wc_get_order_id_by_order_key(wc_clean( (!empty($_GET['key']) ? $_GET['key'] : $id) ) );
if (empty($order_id)) {
$order_id = apply_filters(
'woocommerce_thankyou_order_id',
absint($wp->query_vars['order-received'])
);
}

if (empty($order_id)) {

if (empty($_GET['key']) && empty($id) && !is_object($id)) {
return;
}

$order_id = wc_get_order_id_by_order_key(wc_clean( (!empty($_GET['key']) ? $_GET['key'] : (int) $id) ) );

}

if (empty($order_id)) {
return;
}

$order = wc_get_order($order_id);
Expand Down

0 comments on commit 54186f5

Please sign in to comment.