Skip to content

Commit

Permalink
Merge pull request #104 from angelleye/PFWMA-266
Browse files Browse the repository at this point in the history
State Based Rule : PFWMA-266
  • Loading branch information
kcppdevelopers authored Jan 3, 2022
2 parents 3365991 + a367b89 commit afcbf62
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,56 @@ public function angelleye_get_account_for_ec_parallel_payments($gateways, $gatew
if (empty($passed_rules['buyer_countries'])) {
continue;
}



$buyer_states = get_post_meta($value->ID, 'buyer_states', true);
if (!empty($buyer_states)) {
foreach ($buyer_states as $buyer_states_key => $buyer_states_value) {
if (!empty($order_id) && $order_id > 0) {
$order = wc_get_order($order_id);
$billing_state = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_state : $order->get_billing_state();
$shipping_state = version_compare(WC_VERSION, '3.0', '<') ? $order->shipping_state : $order->get_shipping_state();
if (!empty($billing_state) && $billing_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
} elseif (!empty($shipping_state) && $shipping_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
}
} else {
$post_checkout_data = WC()->session->get('post_data');
if (empty($post_checkout_data)) {
$billing_state = version_compare(WC_VERSION, '3.0', '<') ? WC()->customer->get_state() : WC()->customer->get_billing_state();
$shipping_state = version_compare(WC_VERSION, '3.0', '<') ? WC()->customer->get_state() : WC()->customer->get_shipping_state();
if (!empty($billing_state) && $billing_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
} elseif (!empty($shipping_state) && $shipping_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
}
} else {
if (!empty($post_checkout_data['billing_state']) && $post_checkout_data['billing_state'] == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
} elseif (!empty($post_checkout_data['shipping_state']) && $post_checkout_data['shipping_state'] == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
}
}
}
}
} else {
$passed_rules['buyer_states'] = true;
}
if (empty($passed_rules['buyer_states'])) {
continue;
}




$postcode_string = get_post_meta($value->ID, 'postcode', true);
if (!empty($postcode_string)) {
$postcode = explode(',', $postcode_string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,32 @@ public function angelleye_get_multi_account_by_order_total_latest($gateways, $ga
unset($passed_rules);
continue;
}


$buyer_states = get_post_meta($value->ID, 'buyer_states', true);
if (!empty($buyer_states)) {
foreach ($buyer_states as $buyer_states_key => $buyer_states_value) {
if (!empty($gateway_setting->id) && $gateway_setting->id == 'paypal_pro_payflow') {
if (!empty($order_id) && $order_id > 0) {
$order = wc_get_order($order_id);
$billing_state = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_state : $order->get_billing_state();
$shipping_state = version_compare(WC_VERSION, '3.0', '<') ? $order->shipping_state : $order->get_shipping_state();
if (!empty($billing_state) && $billing_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
} elseif (!empty($shipping_state) && $shipping_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
}
}
}
}
} else {
$passed_rules['buyer_states'] = true;
}
if (empty($passed_rules['buyer_states'])) {
unset($result[$key]);
unset($passed_rules);
continue;
}

$postcode_string = get_post_meta($value->ID, 'postcode', true);
if (!empty($postcode_string)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,34 @@ public function angelleye_woocommerce_paypal_args($request, $order) {
unset($passed_rules);
continue;
}

$buyer_states = get_post_meta($value->ID, 'buyer_states', true);
if (!empty($buyer_states)) {
foreach ($buyer_states as $buyer_states_key => $buyer_states_value) {
if (!empty($gateway_setting->id) && $gateway_setting->id == 'paypal') {
if (!empty($order_id) && $order_id > 0) {
$order = wc_get_order($order_id);
$billing_state = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_state : $order->get_billing_state();
$shipping_state = version_compare(WC_VERSION, '3.0', '<') ? $order->shipping_state : $order->get_shipping_state();
if (!empty($billing_state) && $billing_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
} elseif(!empty($shipping_state) && $shipping_state == $buyer_states_value) {
$passed_rules['buyer_states'] = true;
break;
}
}
}
}
} else {
$passed_rules['buyer_states'] = true;
}
if (empty($passed_rules['buyer_states'])) {
unset($result[$key]);
unset($passed_rules);
continue;
}

$postcode_string = get_post_meta($value->ID, 'postcode', true);
if (!empty($postcode_string)) {
$postcode = explode(',', $postcode_string);
Expand Down
Loading

0 comments on commit afcbf62

Please sign in to comment.