mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #960 from woocommerce/PCP-958-add-contact-message-in-oxxo-payment-settings
Enable OXXO/Standard Card button, add contact message and ensure accepts non physical products (958)
This commit is contained in:
commit
bbe66a75fe
6 changed files with 61 additions and 49 deletions
|
@ -1964,10 +1964,6 @@ return array(
|
|||
$fields['disable_cards']['options'] = $card_options;
|
||||
$fields['card_icons']['options'] = array_merge( $dark_versions, $card_options );
|
||||
|
||||
if ( defined( 'PPCP_FLAG_SEPARATE_APM_BUTTONS' ) && PPCP_FLAG_SEPARATE_APM_BUTTONS === false ) {
|
||||
unset( $fields['allow_card_button_gateway'] );
|
||||
}
|
||||
|
||||
return $fields;
|
||||
},
|
||||
|
||||
|
@ -2245,10 +2241,6 @@ return array(
|
|||
return $container->get( 'api.shop.is-latin-america' );
|
||||
},
|
||||
'wcgateway.settings.allow_card_button_gateway' => static function ( ContainerInterface $container ): bool {
|
||||
if ( defined( 'PPCP_FLAG_SEPARATE_APM_BUTTONS' ) && PPCP_FLAG_SEPARATE_APM_BUTTONS === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof ContainerInterface );
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ class OXXOGateway extends WC_Payment_Gateway {
|
|||
$this->id = self::ID;
|
||||
|
||||
$this->method_title = __( 'OXXO', 'woocommerce-paypal-payments' );
|
||||
$this->method_description = __( 'OXXO is a Mexican chain of convenience stores.', 'woocommerce-paypal-payments' );
|
||||
$this->method_description = __( 'OXXO is a Mexican chain of convenience stores.<br />*Get PayPal account permission to use OXXO payment functionality by contacting us at (+52) 800-925-0304', 'woocommerce-paypal-payments' );
|
||||
|
||||
$this->title = $this->get_option( 'title', $this->method_title );
|
||||
$this->description = $this->get_option( 'description', __( 'OXXO allows you to pay bills and online purchases in-store with cash.', 'woocommerce-paypal-payments' ) );
|
||||
|
|
|
@ -35,14 +35,6 @@ class CheckoutHelper {
|
|||
if ( $cart_total < $minimum || $cart_total > $maximum ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$items = $cart->get_cart_contents();
|
||||
foreach ( $items as $item ) {
|
||||
$product = wc_get_product( $item['product_id'] );
|
||||
if ( is_a( $product, WC_Product::class ) && ! $this->is_physical_product( $product ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_wc_endpoint_url( 'order-pay' ) ) {
|
||||
|
@ -61,15 +53,6 @@ class CheckoutHelper {
|
|||
if ( $order_total < $minimum || $order_total > $maximum ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $order->get_items() as $item_id => $item ) {
|
||||
if ( is_a( $item, WC_Order_Item_Product::class ) ) {
|
||||
$product = wc_get_product( $item->get_product_id() );
|
||||
if ( is_a( $product, WC_Product::class ) && ! $this->is_physical_product( $product ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ declare( strict_types=1 );
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
||||
|
||||
use WC_Order;
|
||||
use WC_Order_Item_Product;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
|
@ -66,12 +67,66 @@ class PayUponInvoiceHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( ! $this->is_valid_currency() ) {
|
||||
if (
|
||||
! $this->is_valid_product()
|
||||
|| ! $this->is_valid_currency()
|
||||
|| ! $this->checkout_helper->is_checkout_amount_allowed( 5, 2500 )
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $this->checkout_helper->is_checkout_amount_allowed( 5, 2500 ) ) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether PUI gateway is enabled.
|
||||
*
|
||||
* @return bool True if PUI gateway is enabled, otherwise false.
|
||||
*/
|
||||
public function is_pui_gateway_enabled(): bool {
|
||||
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
|
||||
return isset( $gateway_settings['enabled'] ) && $gateway_settings['enabled'] === 'yes' && 'DE' === $this->api_shop_country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if product is valid for PUI.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_valid_product(): bool {
|
||||
$cart = WC()->cart ?? null;
|
||||
if ( $cart && ! is_checkout_pay_page() ) {
|
||||
$items = $cart->get_cart_contents();
|
||||
foreach ( $items as $item ) {
|
||||
$product = wc_get_product( $item['product_id'] );
|
||||
if ( $product && ! $this->checkout_helper->is_physical_product( $product ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_wc_endpoint_url( 'order-pay' ) ) {
|
||||
/**
|
||||
* Needed for WordPress `query_vars`.
|
||||
*
|
||||
* @psalm-suppress InvalidGlobal
|
||||
*/
|
||||
global $wp;
|
||||
|
||||
if ( isset( $wp->query_vars['order-pay'] ) && absint( $wp->query_vars['order-pay'] ) > 0 ) {
|
||||
$order_id = absint( $wp->query_vars['order-pay'] );
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( is_a( $order, WC_Order::class ) ) {
|
||||
foreach ( $order->get_items() as $item_id => $item ) {
|
||||
if ( is_a( $item, WC_Order_Item_Product::class ) ) {
|
||||
$product = wc_get_product( $item->get_product_id() );
|
||||
if ( $product && ! $this->checkout_helper->is_physical_product( $product ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -96,14 +151,4 @@ class PayUponInvoiceHelper {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether PUI gateway is enabled.
|
||||
*
|
||||
* @return bool True if PUI gateway is enabled, otherwise false.
|
||||
*/
|
||||
public function is_pui_gateway_enabled(): bool {
|
||||
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
|
||||
return isset( $gateway_settings['enabled'] ) && $gateway_settings['enabled'] === 'yes' && 'DE' === $this->api_shop_country;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,9 +247,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
( $c->get( 'wcgateway.pay-upon-invoice' ) )->init();
|
||||
}
|
||||
|
||||
if ( defined( 'PPCP_FLAG_OXXO' ) && PPCP_FLAG_OXXO === true ) {
|
||||
( $c->get( 'wcgateway.oxxo' ) )->init();
|
||||
}
|
||||
( $c->get( 'wcgateway.oxxo' ) )->init();
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -283,10 +281,6 @@ class WCGatewayModule implements ModuleInterface {
|
|||
add_action(
|
||||
'wc_ajax_ppc-oxxo',
|
||||
static function () use ( $c ) {
|
||||
if ( defined( 'PPCP_FLAG_OXXO' ) && PPCP_FLAG_OXXO === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$endpoint = $c->get( 'wcgateway.endpoint.oxxo' );
|
||||
$endpoint->handle_request();
|
||||
}
|
||||
|
@ -359,7 +353,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
$methods[] = $container->get( 'wcgateway.pay-upon-invoice-gateway' );
|
||||
}
|
||||
|
||||
if ( defined( 'PPCP_FLAG_OXXO' ) && PPCP_FLAG_OXXO === true && 'MX' === $shop_country ) {
|
||||
if ( 'MX' === $shop_country ) {
|
||||
$methods[] = $container->get( 'wcgateway.oxxo-gateway' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue