Skip to content

Commit bf5de1c

Browse files
authored
Merge pull request #33 from saucal/feature/alpha-release
Disable specific features for an alpha release
2 parents d7d3119 + 13e6b95 commit bf5de1c

4 files changed

+54
-12
lines changed

includes/class-wc-gateway-amazon-payments-advanced-abstract.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,6 @@ public function get_form_fields() {
275275
'no' => __( 'No', 'woocommerce-gateway-amazon-payments-advanced' ),
276276
),
277277
),
278-
'subscriptions_enabled' => array(
279-
'title' => __( 'Subscriptions support', 'woocommerce-gateway-amazon-payments-advanced' ),
280-
'label' => __( 'Enable Subscriptions for carts that contain Subscription items (requires WooCommerce Subscriptions to be installed)', 'woocommerce-gateway-amazon-payments-advanced' ),
281-
'type' => 'select',
282-
'description' => __( 'This will enable support for Subscriptions and make transactions more securely', 'woocommerce-gateway-amazon-payments-advanced' ),
283-
'default' => 'yes',
284-
'options' => array(
285-
'yes' => __( 'Yes', 'woocommerce-gateway-amazon-payments-advanced' ),
286-
'no' => __( 'No', 'woocommerce-gateway-amazon-payments-advanced' ),
287-
),
288-
),
289278
'advanced_configuration' => array(
290279
'title' => __( 'Advanced configurations', 'woocommerce-gateway-amazon-payments-advanced' ),
291280
'type' => 'title',

includes/class-wc-gateway-amazon-payments-advanced-subscriptions.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function __construct() {
3434

3535
// WC Subscription Hook
3636
add_filter( 'woocommerce_subscriptions_process_payment_for_change_method_via_pay_shortcode', array( $this, 'filter_payment_method_changed_result' ), 10, 2 );
37+
38+
add_filter( 'woocommerce_amazon_pa_form_fields_before_legacy', array( $this, 'add_enable_subscriptions_field' ) );
3739
}
3840

3941
/**
@@ -749,4 +751,51 @@ public function add_subscription_support( $supports ) {
749751

750752
return $supports;
751753
}
754+
755+
public static function array_insert( $array, $element, $key, $operation = 1 ) {
756+
$keys = array_keys( $array );
757+
$pos = array_search( $key, $keys, true );
758+
759+
switch ( $operation ) {
760+
case 1:
761+
$read_until = $pos + $operation;
762+
$read_from = $pos + $operation;
763+
break;
764+
case 0:
765+
$read_until = $pos;
766+
$read_from = $pos + 1;
767+
break;
768+
case -1:
769+
$read_until = $pos;
770+
$read_from = $pos;
771+
break;
772+
}
773+
774+
$first = array_slice( $array, 0, $read_until, true );
775+
$last = array_slice( $array, $read_from, null, true );
776+
return $first + $element + $last;
777+
}
778+
779+
public function add_enable_subscriptions_field( $fields ) {
780+
$fields = self::array_insert(
781+
$fields,
782+
array(
783+
'subscriptions_enabled' => array(
784+
'title' => __( 'Subscriptions support', 'woocommerce-gateway-amazon-payments-advanced' ),
785+
'label' => __( 'Enable Subscriptions for carts that contain Subscription items (requires WooCommerce Subscriptions to be installed)', 'woocommerce-gateway-amazon-payments-advanced' ),
786+
'type' => 'select',
787+
'description' => __( 'This will enable support for Subscriptions and make transactions more securely', 'woocommerce-gateway-amazon-payments-advanced' ),
788+
'default' => 'yes',
789+
'options' => array(
790+
'yes' => __( 'Yes', 'woocommerce-gateway-amazon-payments-advanced' ),
791+
'no' => __( 'No', 'woocommerce-gateway-amazon-payments-advanced' ),
792+
),
793+
),
794+
),
795+
'advanced_configuration',
796+
-1
797+
);
798+
799+
return $fields;
800+
}
752801
}

includes/class-wc-gateway-amazon-payments-advanced.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function __construct() {
3838
public function is_available() {
3939
$is_available = parent::is_available() && ! empty( $this->settings['merchant_id'] );
4040

41+
if ( function_exists( 'is_checkout_pay_page' ) && is_checkout_pay_page() ) { // TODO: Implement order pay view.
42+
$is_available = false;
43+
}
44+
4145
return apply_filters( 'woocommerce_amazon_pa_is_gateway_available', $is_available );
4246
}
4347

woocommerce-gateway-amazon-payments-advanced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Plugin Name: WooCommerce Amazon Pay
1010
* Plugin URI: https://woocommerce.com/products/pay-with-amazon/
1111
* Description: Amazon Pay is embedded directly into your existing web site, and all the buyer interactions with Amazon Pay and Login with Amazon take place in embedded widgets so that the buyer never leaves your site. Buyers can log in using their Amazon account, select a shipping address and payment method, and then confirm their order. Requires an Amazon Pay seller account and supports USA, UK, Germany, France, Italy, Spain, Luxembourg, the Netherlands, Sweden, Portugal, Hungary, Denmark, and Japan.
12-
* Version: 2.0.0
12+
* Version: 2.0.0-alpha1
1313
* Author: WooCommerce
1414
* Author URI: https://woocommerce.com
1515
*

0 commit comments

Comments
 (0)