plugin updates
This commit is contained in:
@@ -56,7 +56,7 @@ class DefaultMarketingRecommendations {
|
||||
|
||||
return array(
|
||||
array(
|
||||
'title' => 'Google Listings and Ads',
|
||||
'title' => 'Google for WooCommerce',
|
||||
'description' => __( 'Get in front of shoppers and drive traffic so you can grow your business with Smart Shopping Campaigns and free listings.', 'woocommerce' ),
|
||||
'url' => "https://woocommerce.com/products/google-listings-and-ads/{$utm_string}",
|
||||
'direct_install' => true,
|
||||
|
||||
@@ -165,7 +165,7 @@ class TaskLists {
|
||||
),
|
||||
),
|
||||
'tasks' => array(
|
||||
'StoreConnect',
|
||||
'ExtendStore',
|
||||
'AdditionalPayments',
|
||||
'GetMobileApp',
|
||||
),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks;
|
||||
|
||||
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
|
||||
use Jetpack_Gutenberg;
|
||||
use WP_Post;
|
||||
|
||||
/**
|
||||
* Customize Your Store Task
|
||||
@@ -24,23 +24,24 @@ class CustomizeStore extends Task {
|
||||
// Hook to remove unwanted UI elements when users are viewing with ?cys-hide-admin-bar=true.
|
||||
add_action( 'wp_head', array( $this, 'possibly_remove_unwanted_ui_elements' ) );
|
||||
|
||||
add_action( 'save_post_wp_global_styles', array( $this, 'mark_task_as_complete' ), 10, 3 );
|
||||
add_action( 'save_post_wp_template', array( $this, 'mark_task_as_complete' ), 10, 3 );
|
||||
add_action( 'save_post_wp_template_part', array( $this, 'mark_task_as_complete' ), 10, 3 );
|
||||
add_action( 'save_post_wp_global_styles', array( $this, 'mark_task_as_complete_block_theme' ), 10, 3 );
|
||||
add_action( 'save_post_wp_template', array( $this, 'mark_task_as_complete_block_theme' ), 10, 3 );
|
||||
add_action( 'save_post_wp_template_part', array( $this, 'mark_task_as_complete_block_theme' ), 10, 3 );
|
||||
add_action( 'customize_save_after', array( $this, 'mark_task_as_complete_classic_theme' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the CYS task as complete whenever the user updates their global styles.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param \WP_Post $post Post object.
|
||||
* @param bool $update Whether this is an existing post being updated.
|
||||
* @param int $post_id Post ID.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param bool $update Whether this is an existing post being updated.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function mark_task_as_complete( $post_id, $post, $update ) {
|
||||
if ( $post instanceof \WP_Post ) {
|
||||
$is_cys_complete = '{"version": 2, "isGlobalStylesUserThemeJSON": true }' !== $post->post_content || in_array( $post->post_type, array( 'wp_template', 'wp_template_part' ), true );
|
||||
public function mark_task_as_complete_block_theme( $post_id, $post, $update ) {
|
||||
if ( $post instanceof WP_Post ) {
|
||||
$is_cys_complete = $this->has_custom_global_styles( $post ) || $this->has_custom_template( $post );
|
||||
|
||||
if ( $is_cys_complete ) {
|
||||
update_option( 'woocommerce_admin_customize_store_completed', 'yes' );
|
||||
@@ -48,6 +49,15 @@ class CustomizeStore extends Task {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the CYS task as complete whenever the user saves the customizer changes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function mark_task_as_complete_classic_theme() {
|
||||
update_option( 'woocommerce_admin_customize_store_completed', 'yes' );
|
||||
}
|
||||
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
@@ -227,11 +237,6 @@ class CustomizeStore extends Task {
|
||||
* @since 8.0.3
|
||||
*/
|
||||
do_action( 'enqueue_block_editor_assets' );
|
||||
|
||||
// Load Jetpack's block editor assets because they are not enqueued by default.
|
||||
if ( class_exists( 'Jetpack_Gutenberg' ) ) {
|
||||
Jetpack_Gutenberg::enqueue_block_editor_assets();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,4 +265,33 @@ class CustomizeStore extends Task {
|
||||
</style>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the post has custom global styles stored (if it is different from the default global styles).
|
||||
*
|
||||
* @param WP_Post $post The post object.
|
||||
* @return bool
|
||||
*/
|
||||
private function has_custom_global_styles( WP_Post $post ) {
|
||||
$required_keys = array( 'version', 'isGlobalStylesUserThemeJSON' );
|
||||
|
||||
$json_post_content = json_decode( $post->post_content, true );
|
||||
if ( is_null( $json_post_content ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$post_content_keys = array_keys( $json_post_content );
|
||||
|
||||
return ! empty( array_diff( $post_content_keys, $required_keys ) ) || ! empty( array_diff( $required_keys, $post_content_keys ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the post is a template or a template part.
|
||||
*
|
||||
* @param WP_Post $post The post object.
|
||||
* @return bool Whether the post is a template or a template part.
|
||||
*/
|
||||
private function has_custom_template( WP_Post $post ) {
|
||||
return in_array( $post->post_type, array( 'wp_template', 'wp_template_part' ), true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ class ExperimentalShippingRecommendation extends Task {
|
||||
* @return bool
|
||||
*/
|
||||
public function can_view() {
|
||||
return Features::is_enabled( 'shipping-smart-defaults' );
|
||||
return Features::is_enabled( 'shipping-smart-defaults' ) &&
|
||||
! PluginsHelper::is_plugin_active( 'woocommerce-shipping' ) &&
|
||||
! PluginsHelper::is_plugin_active( 'woocommerce-tax' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,16 +5,16 @@ namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks;
|
||||
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
|
||||
|
||||
/**
|
||||
* Connect store to WooCommerce.com Task
|
||||
* ExtendStore Task
|
||||
*/
|
||||
class StoreConnect extends Task {
|
||||
class ExtendStore extends Task {
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_id() {
|
||||
return 'connect-store';
|
||||
return 'extend-store';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ class StoreConnect extends Task {
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
return __( 'Manage your WooCommerce.com Marketplace subscriptions', 'woocommerce' );
|
||||
return __( 'Enhance your store with extensions', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ class StoreConnect extends Task {
|
||||
* @return bool
|
||||
*/
|
||||
public function is_complete() {
|
||||
return \WC_Helper::is_site_connected();
|
||||
return $this->is_visited();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ class StoreConnect extends Task {
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dismissable() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +68,6 @@ class StoreConnect extends Task {
|
||||
* @return string
|
||||
*/
|
||||
public function get_action_url() {
|
||||
return admin_url( 'admin.php?page=wc-admin&tab=my-subscriptions&path=/extensions' );
|
||||
return admin_url( 'admin.php?page=wc-admin&path=/extensions' );
|
||||
}
|
||||
}
|
||||
@@ -77,11 +77,12 @@ class Payments extends Task {
|
||||
*/
|
||||
public function can_view() {
|
||||
$woocommerce_payments = $this->task_list->get_task( 'woocommerce-payments' );
|
||||
// Make sure the task is mutually exclusive with the WooPayments task.
|
||||
return Features::is_enabled( 'payment-gateway-suggestions' ) && ! $woocommerce_payments->can_view();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the store has any enabled gateways.
|
||||
* Check if the store has any enabled gateways, other than WooPayments.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -90,7 +91,8 @@ class Payments extends Task {
|
||||
$enabled_gateways = array_filter(
|
||||
$gateways,
|
||||
function( $gateway ) {
|
||||
return 'yes' === $gateway->enabled && 'woocommerce_payments' !== $gateway->id;
|
||||
// Filter out any WooPayments gateways as this task is mutually exclusive with the WooPayments task.
|
||||
return 'yes' === $gateway->enabled && 0 !== strpos( $gateway->id, 'woocommerce_payments' );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -127,9 +127,11 @@ class Tax extends Task {
|
||||
*/
|
||||
public function get_additional_data() {
|
||||
return array(
|
||||
'avalara_activated' => PluginsHelper::is_plugin_active( 'woocommerce-avatax' ),
|
||||
'tax_jar_activated' => class_exists( 'WC_Taxjar' ),
|
||||
'woocommerce_tax_countries' => self::get_automated_support_countries(),
|
||||
'avalara_activated' => PluginsHelper::is_plugin_active( 'woocommerce-avatax' ),
|
||||
'tax_jar_activated' => class_exists( 'WC_Taxjar' ),
|
||||
'woocommerce_tax_activated' => PluginsHelper::is_plugin_active( 'woocommerce-tax' ),
|
||||
'woocommerce_shipping_activated' => PluginsHelper::is_plugin_active( 'woocommerce-shipping' ),
|
||||
'woocommerce_tax_countries' => self::get_automated_support_countries(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,8 +103,7 @@ class WooCommercePayments extends Task {
|
||||
public function can_view() {
|
||||
$payments = $this->task_list->get_task( 'payments' );
|
||||
|
||||
return ! $payments->is_complete() && // Do not re-display the task if the "add payments" task has already been completed.
|
||||
self::is_installed() &&
|
||||
return ! $payments->is_complete() && // Do not re-display the task if the general "Payments" task has already been completed.
|
||||
self::is_supported();
|
||||
}
|
||||
|
||||
@@ -175,7 +174,7 @@ class WooCommercePayments extends Task {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the store is in a supported country.
|
||||
* Check if the store is in a WooPayments supported country.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,13 @@ class DefaultPaymentGateways {
|
||||
'CA',
|
||||
)
|
||||
),
|
||||
(object) array(
|
||||
'type' => 'or',
|
||||
'operands' => array(
|
||||
self::get_rules_for_wcpay_activated( false ),
|
||||
self::get_rules_for_wcpay_connected( false ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'category_other' => array(),
|
||||
'category_additional' => array(
|
||||
@@ -87,6 +94,13 @@ class DefaultPaymentGateways {
|
||||
'AU',
|
||||
)
|
||||
),
|
||||
(object) array(
|
||||
'type' => 'or',
|
||||
'operands' => array(
|
||||
self::get_rules_for_wcpay_activated( false ),
|
||||
self::get_rules_for_wcpay_connected( false ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'category_other' => array(),
|
||||
'category_additional' => array(
|
||||
@@ -250,6 +264,19 @@ class DefaultPaymentGateways {
|
||||
)
|
||||
),
|
||||
self::get_rules_for_cbd( false ),
|
||||
(object) array(
|
||||
'type' => 'or',
|
||||
'operands' => array(
|
||||
(object) array(
|
||||
'type' => 'not',
|
||||
'operand' => array(
|
||||
self::get_rules_for_countries( self::get_wcpay_countries() ),
|
||||
),
|
||||
),
|
||||
self::get_rules_for_wcpay_activated( false ),
|
||||
self::get_rules_for_wcpay_connected( false ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'category_other' => array(),
|
||||
'category_additional' => array(
|
||||
@@ -862,6 +889,47 @@ class DefaultPaymentGateways {
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => 'woocommerce_payments:bnpl',
|
||||
'title' => __( 'Activate BNPL instantly on WooPayments', 'woocommerce' ),
|
||||
'content' => __(
|
||||
'The world’s favorite buy now, pay later options and many more are right at your fingertips with WooPayments — all from one dashboard, without needing multiple extensions and logins.',
|
||||
'woocommerce'
|
||||
),
|
||||
'image' => WC_ADMIN_IMAGES_FOLDER_URL . '/onboarding/wcpay-bnpl.svg',
|
||||
'image_72x72' => WC_ADMIN_IMAGES_FOLDER_URL . '/onboarding/wcpay-bnpl.svg',
|
||||
'plugins' => array( 'woocommerce-payments' ),
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries(
|
||||
array_intersect(
|
||||
array(
|
||||
'US',
|
||||
'CA',
|
||||
'AU',
|
||||
'AT',
|
||||
'BE',
|
||||
'CH',
|
||||
'DK',
|
||||
'ES',
|
||||
'FI',
|
||||
'FR',
|
||||
'DE',
|
||||
'GB',
|
||||
'IT',
|
||||
'NL',
|
||||
'NO',
|
||||
'PL',
|
||||
'SE',
|
||||
'NZ',
|
||||
),
|
||||
self::get_wcpay_countries()
|
||||
),
|
||||
),
|
||||
self::get_rules_for_cbd( false ),
|
||||
self::get_rules_for_wcpay_activated( true ),
|
||||
self::get_rules_for_wcpay_connected( true ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => 'zipmoney',
|
||||
'title' => __( 'Zip Co - Buy Now, Pay Later', 'woocommerce' ),
|
||||
@@ -976,7 +1044,7 @@ class DefaultPaymentGateways {
|
||||
* Get default rules for CBD based on given argument.
|
||||
*
|
||||
* @param bool $should_have Whether or not the store should have CBD as an industry (true) or not (false).
|
||||
* @return array Rules to match.
|
||||
* @return object Rules to match.
|
||||
*/
|
||||
public static function get_rules_for_cbd( $should_have ) {
|
||||
return (object) array(
|
||||
@@ -1002,6 +1070,62 @@ class DefaultPaymentGateways {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default rules for the WooPayments plugin being installed and activated.
|
||||
*
|
||||
* @param bool $should_be Whether WooPayments should be activated.
|
||||
*
|
||||
* @return object Rules to match.
|
||||
*/
|
||||
public static function get_rules_for_wcpay_activated( $should_be ) {
|
||||
$active_rule = (object) array(
|
||||
'type' => 'plugins_activated',
|
||||
'plugins' => array( 'woocommerce-payments' ),
|
||||
);
|
||||
|
||||
if ( $should_be ) {
|
||||
return $active_rule;
|
||||
}
|
||||
|
||||
return (object) array(
|
||||
'type' => 'not',
|
||||
'operand' => array( $active_rule ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default rules for WooPayments being connected or not.
|
||||
*
|
||||
* This does not include the check for the WooPayments plugin to be active.
|
||||
*
|
||||
* @param bool $should_be Whether WooPayments should be connected.
|
||||
*
|
||||
* @return object Rules to match.
|
||||
*/
|
||||
public static function get_rules_for_wcpay_connected( $should_be ) {
|
||||
return (object) array(
|
||||
'type' => 'option',
|
||||
'transformers' => array(
|
||||
// Extract only the 'data' key from the option.
|
||||
(object) array(
|
||||
'use' => 'dot_notation',
|
||||
'arguments' => (object) array(
|
||||
'path' => 'data',
|
||||
),
|
||||
),
|
||||
// Extract the keys from the data array.
|
||||
(object) array(
|
||||
'use' => 'array_keys',
|
||||
),
|
||||
),
|
||||
'option_name' => 'wcpay_account_data',
|
||||
// The rule will be look for the 'account_id' key in the account data array.
|
||||
'operation' => $should_be ? 'contains' : '!contains',
|
||||
'value' => 'account_id',
|
||||
'default' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recommendation priority for a given payment gateway by id and country.
|
||||
* If country is not supported, return null.
|
||||
@@ -1013,6 +1137,8 @@ class DefaultPaymentGateways {
|
||||
private static function get_recommendation_priority( $gateway_id, $country_code ) {
|
||||
$recommendation_priority_map = array(
|
||||
'US' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1023,6 +1149,8 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
),
|
||||
'CA' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1032,6 +1160,8 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
),
|
||||
'AT' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1041,6 +1171,8 @@ class DefaultPaymentGateways {
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'BE' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1049,26 +1181,63 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'BG' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'HR' => array( 'woocommerce_payments', 'ppcp-gateway' ),
|
||||
'BG' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'HR' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'CH' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'mollie_wc_gateway_banktransfer',
|
||||
'klarna_payments',
|
||||
),
|
||||
'CY' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'amazon_payments_advanced' ),
|
||||
'CZ' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'CY' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'CZ' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'DK' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'klarna_payments',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'EE' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'airwallex_main' ),
|
||||
'EE' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'airwallex_main',
|
||||
),
|
||||
'ES' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1078,6 +1247,8 @@ class DefaultPaymentGateways {
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'FI' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1086,6 +1257,8 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
),
|
||||
'FR' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1096,6 +1269,8 @@ class DefaultPaymentGateways {
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'DE' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1105,6 +1280,8 @@ class DefaultPaymentGateways {
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'GB' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1114,9 +1291,25 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'GR' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'airwallex_main' ),
|
||||
'HU' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'amazon_payments_advanced' ),
|
||||
'GR' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'airwallex_main',
|
||||
),
|
||||
'HU' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'IE' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1125,6 +1318,8 @@ class DefaultPaymentGateways {
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'IT' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1133,11 +1328,38 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'LV' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'LT' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'LU' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'amazon_payments_advanced' ),
|
||||
'MT' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'LV' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'LT' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'LU' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'MT' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'NL' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1146,8 +1368,18 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'NO' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'kco', 'klarna_payments' ),
|
||||
'NO' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'kco',
|
||||
'klarna_payments',
|
||||
),
|
||||
'PL' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1156,16 +1388,39 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
),
|
||||
'PT' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'airwallex_main',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'RO' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'SK' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway' ),
|
||||
'SL' => array( 'woocommerce_payments', 'stripe', 'ppcp-gateway', 'amazon_payments_advanced' ),
|
||||
'RO' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'SK' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'SL' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'SE' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
@@ -1194,6 +1449,8 @@ class DefaultPaymentGateways {
|
||||
'UY' => array( 'woo-mercado-pago-custom', 'ppcp-gateway' ),
|
||||
'VE' => array( 'ppcp-gateway' ),
|
||||
'AU' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'airwallex_main',
|
||||
@@ -1203,6 +1460,8 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
),
|
||||
'NZ' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'airwallex_main',
|
||||
@@ -1210,6 +1469,8 @@ class DefaultPaymentGateways {
|
||||
'klarna_payments',
|
||||
),
|
||||
'HK' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'airwallex_main',
|
||||
@@ -1217,13 +1478,22 @@ class DefaultPaymentGateways {
|
||||
'payoneer-checkout',
|
||||
),
|
||||
'JP' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'ppcp-gateway',
|
||||
'square_credit_card',
|
||||
'amazon_payments_advanced',
|
||||
),
|
||||
'SG' => array( 'woocommerce_payments', 'stripe', 'airwallex_main', 'ppcp-gateway' ),
|
||||
'SG' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
'stripe',
|
||||
'airwallex_main',
|
||||
'ppcp-gateway',
|
||||
),
|
||||
'CN' => array( 'airwallex_main', 'ppcp-gateway', 'payoneer-checkout' ),
|
||||
'FJ' => array(),
|
||||
'GU' => array(),
|
||||
@@ -1232,7 +1502,11 @@ class DefaultPaymentGateways {
|
||||
'ZA' => array( 'payfast', 'paystack' ),
|
||||
'NG' => array( 'paystack' ),
|
||||
'GH' => array( 'paystack' ),
|
||||
'AE' => array( 'woocommerce_payments' ),
|
||||
'AE' => array(
|
||||
'woocommerce_payments:with-in-person-payments',
|
||||
'woocommerce_payments:without-in-person-payments',
|
||||
'woocommerce_payments',
|
||||
),
|
||||
);
|
||||
|
||||
// If the country code is not in the list, return default priority.
|
||||
|
||||
@@ -16,15 +16,33 @@ class EvaluateSuggestion {
|
||||
/**
|
||||
* Evaluates the spec and returns the suggestion.
|
||||
*
|
||||
* @param object|array $spec The suggestion to evaluate.
|
||||
* @param object|array $spec The suggestion to evaluate.
|
||||
* @param array $logger_args Optional. Arguments for the rule evaluator logger.
|
||||
*
|
||||
* @return object The evaluated suggestion.
|
||||
*/
|
||||
public static function evaluate( $spec ) {
|
||||
public static function evaluate( $spec, $logger_args = array() ) {
|
||||
$rule_evaluator = new RuleEvaluator();
|
||||
$suggestion = is_array( $spec ) ? (object) $spec : clone $spec;
|
||||
|
||||
if ( isset( $suggestion->is_visible ) ) {
|
||||
$is_visible = $rule_evaluator->evaluate( $suggestion->is_visible );
|
||||
// Determine the suggestion's logger slug.
|
||||
$logger_slug = ! empty( $suggestion->id ) ? $suggestion->id : '';
|
||||
// If the suggestion has no ID, use the title to generate a slug.
|
||||
if ( empty( $logger_slug ) ) {
|
||||
$logger_slug = ! empty( $suggestion->title ) ? sanitize_title_with_dashes( trim( $suggestion->title ) ) : 'anonymous-suggestion';
|
||||
}
|
||||
|
||||
// Evaluate the visibility of the suggestion.
|
||||
$is_visible = $rule_evaluator->evaluate(
|
||||
$suggestion->is_visible,
|
||||
null,
|
||||
array(
|
||||
'slug' => $logger_slug,
|
||||
'source' => $logger_args['source'] ?? 'wc-payment-gateway-suggestions',
|
||||
)
|
||||
);
|
||||
|
||||
$suggestion->is_visible = $is_visible;
|
||||
}
|
||||
|
||||
@@ -35,15 +53,17 @@ class EvaluateSuggestion {
|
||||
* Evaluates the specs and returns the visible suggestions.
|
||||
*
|
||||
* @param array $specs payment suggestion spec array.
|
||||
* @param array $logger_args Optional. Arguments for the rule evaluator logger.
|
||||
*
|
||||
* @return array The visible suggestions and errors.
|
||||
*/
|
||||
public static function evaluate_specs( $specs ) {
|
||||
public static function evaluate_specs( $specs, $logger_args = array() ) {
|
||||
$suggestions = array();
|
||||
$errors = array();
|
||||
|
||||
foreach ( $specs as $spec ) {
|
||||
try {
|
||||
$suggestion = self::evaluate( $spec );
|
||||
$suggestion = self::evaluate( $spec, $logger_args );
|
||||
if ( ! property_exists( $suggestion, 'is_visible' ) || $suggestion->is_visible ) {
|
||||
$suggestions[] = $suggestion;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class Init {
|
||||
$editor_settings = $this->get_product_editor_settings();
|
||||
|
||||
$script_handle = 'wc-admin-edit-product';
|
||||
wp_register_script( $script_handle, '', array(), '0.1.0', true );
|
||||
wp_register_script( $script_handle, '', array( 'wp-blocks' ), '0.1.0', true );
|
||||
wp_enqueue_script( $script_handle );
|
||||
wp_add_inline_script(
|
||||
$script_handle,
|
||||
@@ -150,9 +150,10 @@ class Init {
|
||||
* Enqueue styles needed for the rich text editor.
|
||||
*/
|
||||
public function enqueue_styles() {
|
||||
if ( ! PageController::is_admin_or_embed_page() ) {
|
||||
if ( ! PageController::is_admin_page() ) {
|
||||
return;
|
||||
}
|
||||
wp_enqueue_style( 'wc-product-editor' );
|
||||
wp_enqueue_style( 'wp-edit-blocks' );
|
||||
wp_enqueue_style( 'wp-format-library' );
|
||||
wp_enqueue_editor();
|
||||
@@ -168,7 +169,7 @@ class Init {
|
||||
* Dequeue conflicting styles.
|
||||
*/
|
||||
public function dequeue_conflicting_styles() {
|
||||
if ( ! PageController::is_admin_or_embed_page() ) {
|
||||
if ( ! PageController::is_admin_page() ) {
|
||||
return;
|
||||
}
|
||||
// Dequeing this to avoid conflicts, until we remove the 'woocommerce-page' class.
|
||||
|
||||
@@ -285,6 +285,24 @@ class DefaultShippingPartners {
|
||||
'learn_more_link' => 'https://woocommerce.com/products/shipping/',
|
||||
'is_visible' => array(
|
||||
self::get_rules_for_countries( array( 'US' ) ),
|
||||
(object) array(
|
||||
'type' => 'not',
|
||||
'operand' => array(
|
||||
(object) array(
|
||||
'type' => 'plugins_activated',
|
||||
'plugins' => array( 'woocommerce-shipping' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
(object) array(
|
||||
'type' => 'not',
|
||||
'operand' => array(
|
||||
(object) array(
|
||||
'type' => 'plugins_activated',
|
||||
'plugins' => array( 'woocommerce-tax' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'available_layouts' => array( 'column' ),
|
||||
),
|
||||
|
||||
@@ -20,14 +20,14 @@ class ShippingPartnerSuggestions extends RemoteSpecsEngine {
|
||||
$locale = get_user_locale();
|
||||
|
||||
$specs = is_array( $specs ) ? $specs : self::get_specs();
|
||||
$results = EvaluateSuggestion::evaluate_specs( $specs );
|
||||
$results = EvaluateSuggestion::evaluate_specs( $specs, array( 'source' => 'wc-shipping-partner-suggestions' ) );
|
||||
$specs_to_return = $results['suggestions'];
|
||||
$specs_to_save = null;
|
||||
|
||||
if ( empty( $specs_to_return ) ) {
|
||||
// When suggestions is empty, replace it with defaults and save for 3 hours.
|
||||
$specs_to_save = DefaultShippingPartners::get_all();
|
||||
$specs_to_return = EvaluateSuggestion::evaluate_specs( $specs_to_save )['suggestions'];
|
||||
$specs_to_return = EvaluateSuggestion::evaluate_specs( $specs_to_save, array( 'source' => 'wc-shipping-partner-suggestions' ) )['suggestions'];
|
||||
} elseif ( count( $results['errors'] ) > 0 ) {
|
||||
// When suggestions is not empty but has errors, save it for 3 hours.
|
||||
$specs_to_save = $specs;
|
||||
|
||||
Reference in New Issue
Block a user