From 07e5e03c0c18d05e5e124620cdc9d8a077b108c9 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Wed, 10 Apr 2024 18:02:54 +0530 Subject: [PATCH 1/3] revert the press4-410. `Swapping shipping and billing fields in checkout page and also PR 208 which will be of no use once press4-410 it is removed` --- includes/ECommerce.php | 79 ------------------------------------------ 1 file changed, 79 deletions(-) diff --git a/includes/ECommerce.php b/includes/ECommerce.php index e815a18b..4b52309c 100644 --- a/includes/ECommerce.php +++ b/includes/ECommerce.php @@ -91,10 +91,6 @@ public function __construct( Container $container ) { add_filter( 'woocommerce_coupons_enabled', array( $this, 'disable_coupon_field_on_cart' ) ); add_filter( 'woocommerce_before_cart', array( $this, 'hide_banner_notice_on_cart' ) ); add_action( 'before_woocommerce_init', array( $this, 'hide_woocommerce_set_up' ) ); - add_filter( 'woocommerce_checkout_fields', array( $this, 'swap_billing_shipping_fields' ), 10, 1 ); - add_filter( 'woocommerce_shipping_fields', array( $this, 'add_phone_number_email_to_shipping_form' ), 10, 1 ); - add_action( 'woocommerce_checkout_create_order', array( $this, 'save_custom_shipping_fields' ), 10, 1 ); - add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'display_custom_shipping_fields_in_admin' ), 10, 1 ); add_action( 'before_woocommerce_init', array( $this, 'custom_payment_gateways_order' ) ); add_action( 'before_woocommerce_init', array( $this, 'dismiss_woo_payments_cta' ) ); add_action( 'load-toplevel_page_' . $container->plugin()->id, array( $this, 'disable_creative_mail_banner' ) ); @@ -391,30 +387,6 @@ public function hide_woocommerce_set_up() { } } - /** - * To show the shipping form first if the ship to destination is set to 'Shipping' - */ - public function swap_billing_shipping_fields( $fields ) { - $shipping_destination = get_option( 'woocommerce_ship_to_destination' ); - if ( $shipping_destination == 'shipping' ) { - add_filter( 'gettext', array( $this, 'update_text' ), 20, 3 ); - ?> - - __( 'Phone Number', 'wp-module-ecommerce' ), - 'required' => true, - 'class' => array( 'form-row-wide' ), - 'clear' => true, - ); - $fields['shipping_email'] = array( - 'label' => __( 'Email Address', 'wp-module-ecommerce' ), - 'required' => true, - 'class' => array( 'form-row-wide' ), - 'clear' => true, - ); - return $fields; - } - - /* - * Save phone number and email fields to order meta - */ - function save_custom_shipping_fields( $order ) { - $shipping_phone = isset( $_POST['shipping_phone'] ) ? sanitize_text_field( $_POST['shipping_phone'] ) : ''; - $shipping_email = isset( $_POST['shipping_email'] ) ? sanitize_email( $_POST['shipping_email'] ) : ''; - - if ( ! empty( $shipping_phone ) ) { - $order->update_meta_data( '_shipping_phone', $shipping_phone ); - } - - if ( ! empty( $shipping_email ) ) { - $order->update_meta_data( '_shipping_email', $shipping_email ); - } - } - - /** - * Display phone number and email fields in order admin - */ - public function display_custom_shipping_fields_in_admin( $order ) { - $shipping_phone = $order->get_meta( '_shipping_phone' ); - $shipping_email = $order->get_meta( '_shipping_email' ); - - if ( ! empty( $shipping_phone ) ) { - echo '

' . __( 'Phone Number', 'wp-module-ecommerce' ) . ': ' . esc_html( $shipping_phone ) . '

'; - } - - if ( ! empty( $shipping_email ) ) { - echo '

' . __( 'Email Address', 'wp-module-ecommerce' ) . ': ' . esc_html( $shipping_email ) . '

'; - } - } - /** * Add promotion (Promote) under WooCommerce Marketing tab */ From c79cad7ada803a1d16a6a471e26af4a527bfa5f3 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Wed, 10 Apr 2024 18:51:17 +0530 Subject: [PATCH 2/3] linting fixes --- includes/ECommerce.php | 223 ++++++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 102 deletions(-) diff --git a/includes/ECommerce.php b/includes/ECommerce.php index 4b52309c..392edf37 100644 --- a/includes/ECommerce.php +++ b/includes/ECommerce.php @@ -94,47 +94,46 @@ public function __construct( Container $container ) { add_action( 'before_woocommerce_init', array( $this, 'custom_payment_gateways_order' ) ); add_action( 'before_woocommerce_init', array( $this, 'dismiss_woo_payments_cta' ) ); add_action( 'load-toplevel_page_' . $container->plugin()->id, array( $this, 'disable_creative_mail_banner' ) ); - add_action( 'activated_plugin', array( $this, 'detect_plugin_activation' ), 10, 1 ); - - $brandNameValue = $container->plugin()->brand; - $this->set_wpnav_collapse_setting($brandNameValue); - - if (($container->plugin()->id === "bluehost" && ($canAccessGlobalCTB || $hasYithExtended)) || ($container->plugin()->id === "hostgator" && $hasYithExtended)) - { - add_filter( 'admin_menu', array($this,'custom_add_promotion_menu_item') ); - add_action( 'woocommerce_product_options_general_product_data', array( $this,'custom_product_general_options')); - add_action( 'woocommerce_product_options_related',array($this,'custom_product_general_options')); - add_action( 'woocommerce_product_data_tabs',array( $this, 'custom_product_write_panel_tabs')); - add_action( 'woocommerce_product_data_panels', array( $this,'promotion_product_data')); - add_action( 'admin_head', array( $this,'action_admin_head')); - }; - - // Handle WonderCart Integrations - if ( is_plugin_active( 'wonder-cart/init.php' ) ) { - $wonder_cart = new WonderCart( $container ); - $wonder_cart->init(); - } - - CaptiveFlow::init(); - WooCommerceBacklink::init( $container ); - register_meta( - 'post', - 'nf_dc_page', - array( - 'type' => 'string', - 'description' => 'Reference to page category', - 'show_in_rest' => true, - 'single' => true, - ) - ); - add_filter( 'newfold-runtime', array( $this, 'add_to_runtime' ) ); - $this->add_filters( - array( 'postbox_classes_page_wpseo_meta', 'postbox_classes_post_wpseo_meta', 'postbox_classes_product_wpseo_meta' ), - function ( $classes ) { - $classes[] = 'closed'; - return $classes; - } - ); + add_action( 'activated_plugin', array( $this, 'detect_plugin_activation' ), 10, 1 ); + + $brandNameValue = $container->plugin()->brand; + $this->set_wpnav_collapse_setting( $brandNameValue ); + + if ( ( $container->plugin()->id === 'bluehost' && ( $canAccessGlobalCTB || $hasYithExtended ) ) || ( $container->plugin()->id === 'hostgator' && $hasYithExtended ) ) { + add_filter( 'admin_menu', array( $this, 'custom_add_promotion_menu_item' ) ); + add_action( 'woocommerce_product_options_general_product_data', array( $this, 'custom_product_general_options' ) ); + add_action( 'woocommerce_product_options_related', array( $this, 'custom_product_general_options' ) ); + add_action( 'woocommerce_product_data_tabs', array( $this, 'custom_product_write_panel_tabs' ) ); + add_action( 'woocommerce_product_data_panels', array( $this, 'promotion_product_data' ) ); + add_action( 'admin_head', array( $this, 'action_admin_head' ) ); + } + + // Handle WonderCart Integrations + if ( is_plugin_active( 'wonder-cart/init.php' ) ) { + $wonder_cart = new WonderCart( $container ); + $wonder_cart->init(); + } + + CaptiveFlow::init(); + WooCommerceBacklink::init( $container ); + register_meta( + 'post', + 'nf_dc_page', + array( + 'type' => 'string', + 'description' => 'Reference to page category', + 'show_in_rest' => true, + 'single' => true, + ) + ); + add_filter( 'newfold-runtime', array( $this, 'add_to_runtime' ) ); + $this->add_filters( + array( 'postbox_classes_page_wpseo_meta', 'postbox_classes_post_wpseo_meta', 'postbox_classes_product_wpseo_meta' ), + function ( $classes ) { + $classes[] = 'closed'; + return $classes; + } + ); // Handle WonderCart Integrations if ( is_plugin_active( 'wonder-cart/init.php' ) ) { @@ -167,10 +166,10 @@ function ( $classes ) { /** * Add multiple filters to a closure * - * @param $tags - * @param $function_to_add - * @param int $priority - * @param int $accepted_args + * @param string|array $tags The filter name or array of filter names + * @param callable $function_to_add The closure to add to the filter + * @param int|array $priority The priority at which the closure should be added + * @param int|array $accepted_args The number of arguments the closure accepts * * @return bool true */ @@ -179,22 +178,26 @@ public static function add_filters( $tags, $function_to_add, $priority = 10, $ac if ( ! is_array( $tags ) ) { $tags = array( $tags ); } - // For each filter name + // For each filter name foreach ( $tags as $index => $tag ) { add_filter( $tag, $function_to_add, (int) ( is_array( $priority ) ? $priority[ $index ] : $priority ), (int) ( is_array( $accepted_args ) ? $accepted_args[ $index ] : $accepted_args ) ); } return true; - } + } + + /** + * Set the wpnav_collapse setting + * + * @param string $brandNameValue The brand name value + */ + public static function set_wpnav_collapse_setting( $brandNameValue ) { - public static function set_wpnav_collapse_setting($brandNameValue) { - - $expiration_time = time() + (10 * 365 * 24 * 60 * 60); - setcookie('nfdbrandname', $brandNameValue, $expiration_time, '/'); - - wp_enqueue_script( 'nfd_wpnavbar_setting', NFD_ECOMMERCE_PLUGIN_URL . 'vendor/newfold-labs/wp-module-ecommerce/includes/wpnavbar.js', array('jquery'), '1.0', true); - - } + $expiration_time = time() + ( 10 * 365 * 24 * 60 * 60 ); + setcookie( 'nfdbrandname', $brandNameValue, $expiration_time, '/' ); + + wp_enqueue_script( 'nfd_wpnavbar_setting', NFD_ECOMMERCE_PLUGIN_URL . 'vendor/newfold-labs/wp-module-ecommerce/includes/wpnavbar.js', array( 'jquery' ), '1.0', true ); + } /** * Loads the textdomain for the module. This applies only to PHP strings. @@ -208,10 +211,20 @@ public static function load_php_textdomain() { ); } + /** + * Update the experience level + */ public static function load_experience_level() { update_option( 'onboarding_experience_level', FlowService::get_experience_level() ); } + /** + * Add values to the runtime object. + * + * @param array $sdk The runtime object. + * + * @return array + */ public function add_to_runtime( $sdk ) { $values = array( 'brand_settings' => Brands::get_config( $this->container ), @@ -223,6 +236,9 @@ public function add_to_runtime( $sdk ) { return array_merge( $sdk, array( 'ecommerce' => $values ) ); } + /** + * Redirect to the dashboard after WooCommerce activation. + */ public function maybe_do_dash_redirect() { $show_dash = get_option( 'nfd_show_dash_after_woo_activation', false ); if ( $show_dash && ! wp_doing_ajax() ) { @@ -319,6 +335,9 @@ public function register_settings() { } } + /** + * Load the textdomains for the module. + */ public function register_textdomains() { $MODULE_LANG_DIR = $this->container->plugin()->dir . 'vendor/newfold-labs/wp-module-ecommerce/languages'; \load_script_textdomain( 'nfd-ecommerce-dependency', 'wp-module-ecommerce', $MODULE_LANG_DIR ); @@ -326,31 +345,33 @@ public function register_textdomains() { \load_textdomain( 'wp-module-ecommerce', $MODULE_LANG_DIR . '/wp-module-ecommerce-' . $current_language . '.mo' ); } - /** - * Load WP dependencies into the page. - */ - public function register_assets() { - $asset_file = NFD_ECOMMERCE_BUILD_DIR . 'index.asset.php'; - if ( file_exists( $asset_file ) ) { - $asset = require $asset_file; - \wp_register_script( - 'nfd-ecommerce-dependency', - NFD_ECOMMERCE_PLUGIN_URL, - array_merge( $asset['dependencies'], array() ), - $asset['version'] - ); - I18nService::load_js_translations( - 'wp-module-ecommerce', - 'nfd-ecommerce-dependency', - NFD_ECOMMERCE_DIR . '/languages' - ); - \wp_enqueue_script( 'nfd-ecommerce-dependency' ); - \wp_enqueue_script( 'nfd_wpnavbar_setting' ); - } - } + /** + * Load WP dependencies into the page. + */ + public function register_assets() { + $asset_file = NFD_ECOMMERCE_BUILD_DIR . 'index.asset.php'; + if ( file_exists( $asset_file ) ) { + $asset = require $asset_file; + \wp_register_script( + 'nfd-ecommerce-dependency', + NFD_ECOMMERCE_PLUGIN_URL, + array_merge( $asset['dependencies'], array() ), + $asset['version'] + ); + I18nService::load_js_translations( + 'wp-module-ecommerce', + 'nfd-ecommerce-dependency', + NFD_ECOMMERCE_DIR . '/languages' + ); + \wp_enqueue_script( 'nfd-ecommerce-dependency' ); + \wp_enqueue_script( 'nfd_wpnavbar_setting' ); + } + } /** * Remove Add coupon field on cart page + * + * @param boolean $enabled The enabled status of the coupon field. */ public function disable_coupon_field_on_cart( $enabled ) { if ( is_cart() ) { @@ -373,39 +394,27 @@ public function hide_banner_notice_on_cart() { container->plugin()->id . '#/store/sales_discounts' ); wp_enqueue_style( 'Create_a_Promotion', NFD_ECOMMERCE_PLUGIN_URL . 'vendor/newfold-labs/wp-module-ecommerce/includes/Promotions.css', array(), '1.0', 'all' ); echo ''; } /** * Add a Custom tab (Prmotions tab) button added below Advance tab + * + * @param array $tabs The tabs. */ - function custom_product_write_panel_tabs( $tabs ) { + public function custom_product_write_panel_tabs( $tabs ) { $tabs['custom_tab'] = array( 'label' => __( 'Promotions', 'wp-module-ecommerce' ), 'target' => 'promotion_product_data', @@ -447,7 +458,7 @@ function custom_product_write_panel_tabs( $tabs ) { /** * Content on click of a Custom tab (Promotions tab) button added below Advance tab */ - function promotion_product_data() { + public function promotion_product_data() { $redirect_url = 'admin.php?page=' . $this->container->plugin()->id . '#/store/sales_discounts'; global $post; echo ''; @@ -472,9 +483,9 @@ function promotion_product_data() { } /** - * change icon for a Custom tab (Promotions tab) button added below Advance tab + * Change icon for a Custom tab (Promotions tab) button added below Advance tab */ - function action_admin_head() { + public function action_admin_head() { echo ''; } + /** + * Change the order of payment gateways + */ public function custom_payment_gateways_order() { $array_data = array( 'pre_install_woocommerce_payments_promotion' => 2, @@ -491,6 +505,9 @@ public function custom_payment_gateways_order() { update_option( 'woocommerce_gateway_order', $array_data ); } + /** + * Dismisses the WooCommerce Payments CTA + */ public function dismiss_woo_payments_cta() { $is_dismissed = get_option( 'wcpay_welcome_page_incentives_dismissed' ); if ( ! is_array( $is_dismissed ) || empty( $is_dismissed ) ) { @@ -498,6 +515,9 @@ public function dismiss_woo_payments_cta() { } } + /** + * Disables the creative mail banner + */ public function disable_creative_mail_banner() { $is_dismissed = get_option( 'ce4wp_ignore_review_notice' ); if ( ! is_array( $is_dismissed ) || empty( $is_dismissed ) ) { @@ -509,7 +529,6 @@ public function disable_creative_mail_banner() { * Activates yith payment plugins (Paypal, Stripe) when woocommerce is activated * * @param string $plugin Path to the plugin file relative - * @param bool $network_activation enable the plugin for all sites * * @return void */ From c530ab1f08923706196d00808ea6eae1dc7f061c Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Wed, 10 Apr 2024 19:20:31 +0530 Subject: [PATCH 3/3] ecommerce version update to 1.3.27 --- composer.lock | 26 +++++++++++++------------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/composer.lock b/composer.lock index a47885d8..ac87856f 100644 --- a/composer.lock +++ b/composer.lock @@ -58,20 +58,20 @@ }, { "name": "newfold-labs/wp-module-ai", - "version": "1.1.7", + "version": "1.1.8", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-ai.git", - "reference": "2d1ea36f2a17c79934f3c41b02316d8d12fd299d" + "reference": "ffc1c06e69bcaf46e7ad10eda147d10a9574bcea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-ai/zipball/2d1ea36f2a17c79934f3c41b02316d8d12fd299d", - "reference": "2d1ea36f2a17c79934f3c41b02316d8d12fd299d", + "url": "https://api.github.com/repos/newfold-labs/wp-module-ai/zipball/ffc1c06e69bcaf46e7ad10eda147d10a9574bcea", + "reference": "ffc1c06e69bcaf46e7ad10eda147d10a9574bcea", "shasum": "" }, "require": { - "newfold-labs/wp-module-data": "^2.3.1" + "newfold-labs/wp-module-data": "^2.4.18" }, "require-dev": { "newfold-labs/wp-php-standards": "^1.2" @@ -96,10 +96,10 @@ ], "description": "A module for providing artificial intelligence capabilities.", "support": { - "source": "https://github.com/newfold-labs/wp-module-ai/tree/1.1.7", + "source": "https://github.com/newfold-labs/wp-module-ai/tree/1.1.8", "issues": "https://github.com/newfold-labs/wp-module-ai/issues" }, - "time": "2024-03-18T11:49:32+00:00" + "time": "2024-04-08T16:04:32+00:00" }, { "name": "newfold-labs/wp-module-coming-soon", @@ -294,16 +294,16 @@ }, { "name": "newfold-labs/wp-module-patterns", - "version": "0.1.15", + "version": "0.1.16", "source": { "type": "git", "url": "https://github.com/newfold-labs/wp-module-patterns.git", - "reference": "4d82192a614f21b5e083fcd2c7893677dd974f9c" + "reference": "0ab410ea66231f2694d4f9d0aafa2e2874000cf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/newfold-labs/wp-module-patterns/zipball/4d82192a614f21b5e083fcd2c7893677dd974f9c", - "reference": "4d82192a614f21b5e083fcd2c7893677dd974f9c", + "url": "https://api.github.com/repos/newfold-labs/wp-module-patterns/zipball/0ab410ea66231f2694d4f9d0aafa2e2874000cf2", + "reference": "0ab410ea66231f2694d4f9d0aafa2e2874000cf2", "shasum": "" }, "require-dev": { @@ -337,10 +337,10 @@ ], "description": "WordPress Cloud Patterns", "support": { - "source": "https://github.com/newfold-labs/wp-module-patterns/tree/0.1.15", + "source": "https://github.com/newfold-labs/wp-module-patterns/tree/0.1.16", "issues": "https://github.com/newfold-labs/wp-module-patterns/issues" }, - "time": "2024-03-15T15:00:55+00:00" + "time": "2024-04-08T19:51:29+00:00" }, { "name": "newfold-labs/wp-module-performance", diff --git a/package-lock.json b/package-lock.json index 15a9076b..7b5af031 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@newfold-labs/wp-module-ecommerce", - "version": "1.3.26", + "version": "1.3.27", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@newfold-labs/wp-module-ecommerce", - "version": "1.3.26", + "version": "1.3.27", "license": "GPL-2.0-or-later", "dependencies": { "@faizaanceg/pandora": "^1.1.1", diff --git a/package.json b/package.json index 99bcacd9..cc1ad8d8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@newfold-labs/wp-module-ecommerce", "description": "Brand Agnostic eCommerce Experience", "license": "GPL-2.0-or-later", - "version": "1.3.26", + "version": "1.3.27", "main": "build/index.js", "files": [ "build/",