Plugin Directory

Changeset 3048574


Ignore:
Timestamp:
03/10/2024 12:10:31 PM (2 years ago)
Author:
techsarai
Message:

3.0.0 - Feature to show only Free Shipping and hide other shipping methods

Location:
user-role-based-shipping-method
Files:
6 edited
3 copied

Legend:

Unmodified
Added
Removed
  • user-role-based-shipping-method/tags/3.0.0/includes/class-pvalley-user-role-based-shipping-manage-shipping.php

    r2673900 r3048574  
    2626            $this->shipping_based_on = ! empty(self::$settings['general_settings_shipping_based_on']) ? self::$settings['general_settings_shipping_based_on'] : array();
    2727            add_filter( 'woocommerce_package_rates', array( $this, 'manage_shipping_methods'), 10, 2 );
     28            add_filter("woocommerce_package_rates", array($this, "hide_shipping_methods"), 999);
     29        }
     30
     31        /**
     32         * Hide shipping methods based on the selected option.
     33         *
     34         * @param $rates
     35         *
     36         * @return array|mixed
     37         */
     38        public function hide_shipping_methods($rates) {
     39            $show_only = ! empty(self::$settings['show_only']) ? self::$settings['show_only'] : "";
     40            switch ($show_only) {
     41                case "free_shipping":
     42                    return $this->show_only_free_shipping( $rates );
     43                default:
     44                    return $rates;
     45            }
     46        }
     47
     48        /**
     49         * Hide all the shipping methods other than Free Shipping method.
     50         *
     51         * it will be applicable only when Free Shipping is available.
     52         *
     53         * It won't hide any shipping methods when there is no Free Shipping methods.
     54         *
     55         * @param $rates
     56         *
     57         * @return array|mixed
     58         */
     59        public function show_only_free_shipping($rates) {
     60            $free = array();
     61            foreach ( $rates as $rate_id => $rate ) {
     62                if ( 'free_shipping' === $rate->method_id ) {
     63                    $free[ $rate_id ] = $rate;
     64                    break;
     65                }
     66            }
     67            return ! empty( $free ) ? $free : $rates;
    2868        }
    2969
  • user-role-based-shipping-method/tags/3.0.0/includes/class-pvalley-user-role-based-shipping-settings.php

    r2278152 r3048574  
    1010         */
    1111        public function __construct() {
    12                
    1312            $this->id    = 'pvalley_role_based_shipping';
    1413            $this->label = __( 'Role Baed Shipping', 'pvalley-user-role-based-shipping' );
     
    7473                            'type'  =>  'checkbox',
    7574                            'id'    => 'pvalley_user_role_based_shipping[general_settings_enable]'
     75                        ),
     76                        "general_settings_hide_shipping_methods"  => array(
     77                            "name"      => __("Hide shipping methods", "pvalley-user-role-based-shipping"),
     78                            "type"      => "select",
     79                            "options"   => array(
     80                                "" => __("Select"),
     81                                "free_shipping" => __("Show Free Shipping Only, hide other shipping methods", "pvalley-user-role-based-shipping")
     82                            ),
     83                            "class"     => "wc-enhanced-select",
     84                            "id"        => "pvalley_user_role_based_shipping[show_only]",
     85                            "desc"      => "It will be applied only if Free Shipping is available during checkout. It's not related to rule matrix. It can be used without rule matrix."
    7686                        ),
    7787                        'general_settings_shipping_based_on'    =>  array(
  • user-role-based-shipping-method/tags/3.0.0/pvalley-user-role-based-shipping.php

    r3036404 r3048574  
    44 * Plugin URI:
    55 * Description: Hide/show shipping methods based on user role and destination country.
    6  * Version: 2.0.1
     6 * Version: 3.0.0
    77 * Author: Pluginvalley
    88 * Author URI:
     
    1111 * Requires at least: 5.0
    1212 * WC requires at least: 3.0.0
    13  * WC tested up to: 8.5.2
     13 * WC tested up to: 8.6.1
    1414 */
    1515
  • user-role-based-shipping-method/tags/3.0.0/readme.txt

    r3036411 r3048574  
    66Requires at least: 5.0
    77Tested up to: 6.4
    8 Stable tag: 2.0.1
     8Stable tag: 3.0.0
    99License: GPLv3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
    1111
    12 Role based Shipping Method Plugin for WooCommerce. Manage Shipping Rates based on User Roles and destination country.
     12Display WooCommerce shipping methods based on User Role and Country. Globally compatible.
    1313
    1414== Introduction ==
    1515
    16 Hide/show woocommerce shipping methods based on user role and destination country.
     16Display WooCommerce shipping methods based on User Role and country, Option to hide all other shipping methods when Free Shipping is available.
    1717
    1818== Description ==
    19 It will allow you to hide/show the WooCommerce Shipping methods based on User Role. It will also allow you to manage the WooCommerce Shipping methods based on Shipping Country. You can use it with Flat Rate / Free Shipping / Local Pickup or any other third party shipping plugin.
     19It will allow you to hide WooCommerce Shipping methods based on user role and country. It is globally compatible i.e. You can use it with Flat Rate / Free Shipping / Local Pickup or any other third party shipping plugin.
     20It also provides you an option to show only Free Shipping when Free Shipping is available during checkout by removing all other shipping methods.
    2021
    21 
    22 Do you wish to provide Woocommerce Shipping Cost based on User Role ?
    23 Do you wish to provide WooCommerce Shipping Cost based on Shipping Country ?
    24 Are you still struggling to setup the Woocommerce Shipping Cost based on User Role and Destination Country ?
     22Do you want to show shipping methods based on user role?
     23Do you want to show shipping methods based on shipping country?
     24Are you still struggling to set up the Woocommerce Shipping Cost based on User Role and Destination Country ?
    2525
    2626Here's the solution for your requirement. Setup Flat Rate / Free Shipping or Shipping Cost using any third Party Plugin and Manage them Which Shipping Cost need to be shown to which user and for which country.
    2727
    2828= Features =
    29  * Manage WooCommerce Shipping Method based on User role.
    30  * Manage WooCommerce Shipping Method based on Country.
    31  * Manage Woocommerce Shipping Method based on User role and Destination Country.
    32  * Manage shipping method based on shipping method name or label
     29 * Display shipping methods based on user role
     30 * Display shipping methods based on shipping country
     31 * Option to hide all other shipping methods and shown only Free Shipping when Free Shipping is available during checkout
    3332
    3433== Installation ==
     
    4342== Frequently Asked Questions ==
    4443
     44= Compatibility? =
     45
     46Globally Compatible. It is compatible with all the shipping methods offered by WooCommerce and third party plugins.
     47
     48= How to display Free Shipping only? =
     49
     50Go to General section in plugin settings page.
     51Enable the plugin and under Hide shipping methods select option to Show Free Shipping Only, hide other shipping methods.
     52Note It's independent of rule matrix.
     53It will only work when Free Shipping is available during checkout.
     54
    4555= How to setup the plugin? =
    4656
     
    5161Woocommerce store info: Assume our store offer three shipping methods - Standard Delivery, Express Shipping, One Day Shipping.
    5262
    53 Case 1: I want to show One Day Shipping method to Administrator user role in USA.
     63Case 1: I want to show One Day Shipping method to Administrator user role in the USA.
    5464
    55 To acheive it add a new rule in Rules settings page.
     65To achieve it add a new rule in Rules settings page.
    5666* Select Administrator in User Role field.
    5767* Select United States in Countries field.
     
    6171* Now go to shop page add any product and recalculate the shipping cost by changing the address, Standard Delivery and Express Shipping method won't be shown.
    6272
    63 Case 2: I want to show Standard Delivery, Express Shipping method to Guest user role in USA.
     73Case 2: I want to show Standard Delivery, Express Shipping method to Guest user role in the USA.
    6474
    65 To acheive it add a new rule in Rules settings page.
     75To achieve it add a new rule in Rules settings page.
    6676* Select Guest in User Role field.
    6777* Select United States in Countries field.
     
    7686
    7787= Plugin not working after setting the plugin? =
    78 If you have done the plugin setup and you still don't see any change in cart/checkout page then please try to recalculate the shipping cost by changing the address because by default woocommerce will show you the cached shipping methods.
     88If you have done the plugin setup, and you still don't see any change in cart/checkout page then please try to recalculate the shipping cost by changing the address because
     89by default woocommerce will show you the cached shipping methods.
    7990
    8091= Sample Video =
     
    88993. Value of Shipping Method to hide
    891004. Shipping method hidden
    90 5. Multiple shipping method rule configuration for sigle user role
     1015. Multiple shipping method rule configuration for single user role
    911026. Shipping method hidden based on label / name
    92103
     
    114125 * Compatibility with WordPress 5.9
    115126 * Compatibility with WooCommerce 6.1.1
    116  * New option to hide shipping method based on shipping method name / title / lable
     127 * New option to hide shipping method based on shipping method name / title / label
    117128
    118129= 2.0.1 =
     
    124135 * Tested with WooCommerce 8.5.2
    125136
     137= 3.0.0 =
     138 * Feature to hide all the shipping methods, and show only free shipping method, when free shipping is available during checkout
     139 * Readme content change
     140 * Tested with WooCommerce 8.6.1
     141
    126142== Upgrade Notice ==
    127143
    128 = 2.0.1 =
    129  * Handled PHP compatibility issue
    130  * Tested with WordPress 6.4.3
    131  * Tested with WooCommerce 8.5.2
     144= 3.0.0 =
     145 * Feature to hide all the shipping methods, and show only free shipping method, when free shipping is available during checkout
     146 * Tested with WooCommerce 8.6.1
  • user-role-based-shipping-method/trunk/includes/class-pvalley-user-role-based-shipping-manage-shipping.php

    r2673900 r3048574  
    2626            $this->shipping_based_on = ! empty(self::$settings['general_settings_shipping_based_on']) ? self::$settings['general_settings_shipping_based_on'] : array();
    2727            add_filter( 'woocommerce_package_rates', array( $this, 'manage_shipping_methods'), 10, 2 );
     28            add_filter("woocommerce_package_rates", array($this, "hide_shipping_methods"), 999);
     29        }
     30
     31        /**
     32         * Hide shipping methods based on the selected option.
     33         *
     34         * @param $rates
     35         *
     36         * @return array|mixed
     37         */
     38        public function hide_shipping_methods($rates) {
     39            $show_only = ! empty(self::$settings['show_only']) ? self::$settings['show_only'] : "";
     40            switch ($show_only) {
     41                case "free_shipping":
     42                    return $this->show_only_free_shipping( $rates );
     43                default:
     44                    return $rates;
     45            }
     46        }
     47
     48        /**
     49         * Hide all the shipping methods other than Free Shipping method.
     50         *
     51         * it will be applicable only when Free Shipping is available.
     52         *
     53         * It won't hide any shipping methods when there is no Free Shipping methods.
     54         *
     55         * @param $rates
     56         *
     57         * @return array|mixed
     58         */
     59        public function show_only_free_shipping($rates) {
     60            $free = array();
     61            foreach ( $rates as $rate_id => $rate ) {
     62                if ( 'free_shipping' === $rate->method_id ) {
     63                    $free[ $rate_id ] = $rate;
     64                    break;
     65                }
     66            }
     67            return ! empty( $free ) ? $free : $rates;
    2868        }
    2969
  • user-role-based-shipping-method/trunk/includes/class-pvalley-user-role-based-shipping-settings.php

    r2278152 r3048574  
    1010         */
    1111        public function __construct() {
    12                
    1312            $this->id    = 'pvalley_role_based_shipping';
    1413            $this->label = __( 'Role Baed Shipping', 'pvalley-user-role-based-shipping' );
     
    7473                            'type'  =>  'checkbox',
    7574                            'id'    => 'pvalley_user_role_based_shipping[general_settings_enable]'
     75                        ),
     76                        "general_settings_hide_shipping_methods"  => array(
     77                            "name"      => __("Hide shipping methods", "pvalley-user-role-based-shipping"),
     78                            "type"      => "select",
     79                            "options"   => array(
     80                                "" => __("Select"),
     81                                "free_shipping" => __("Show Free Shipping Only, hide other shipping methods", "pvalley-user-role-based-shipping")
     82                            ),
     83                            "class"     => "wc-enhanced-select",
     84                            "id"        => "pvalley_user_role_based_shipping[show_only]",
     85                            "desc"      => "It will be applied only if Free Shipping is available during checkout. It's not related to rule matrix. It can be used without rule matrix."
    7686                        ),
    7787                        'general_settings_shipping_based_on'    =>  array(
  • user-role-based-shipping-method/trunk/pvalley-user-role-based-shipping.php

    r3036404 r3048574  
    44 * Plugin URI:
    55 * Description: Hide/show shipping methods based on user role and destination country.
    6  * Version: 2.0.1
     6 * Version: 3.0.0
    77 * Author: Pluginvalley
    88 * Author URI:
     
    1111 * Requires at least: 5.0
    1212 * WC requires at least: 3.0.0
    13  * WC tested up to: 8.5.2
     13 * WC tested up to: 8.6.1
    1414 */
    1515
  • user-role-based-shipping-method/trunk/readme.txt

    r3036411 r3048574  
    66Requires at least: 5.0
    77Tested up to: 6.4
    8 Stable tag: 2.0.1
     8Stable tag: 3.0.0
    99License: GPLv3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
    1111
    12 Role based Shipping Method Plugin for WooCommerce. Manage Shipping Rates based on User Roles and destination country.
     12Display WooCommerce shipping methods based on User Role and Country. Globally compatible.
    1313
    1414== Introduction ==
    1515
    16 Hide/show woocommerce shipping methods based on user role and destination country.
     16Display WooCommerce shipping methods based on User Role and country, Option to hide all other shipping methods when Free Shipping is available.
    1717
    1818== Description ==
    19 It will allow you to hide/show the WooCommerce Shipping methods based on User Role. It will also allow you to manage the WooCommerce Shipping methods based on Shipping Country. You can use it with Flat Rate / Free Shipping / Local Pickup or any other third party shipping plugin.
     19It will allow you to hide WooCommerce Shipping methods based on user role and country. It is globally compatible i.e. You can use it with Flat Rate / Free Shipping / Local Pickup or any other third party shipping plugin.
     20It also provides you an option to show only Free Shipping when Free Shipping is available during checkout by removing all other shipping methods.
    2021
    21 
    22 Do you wish to provide Woocommerce Shipping Cost based on User Role ?
    23 Do you wish to provide WooCommerce Shipping Cost based on Shipping Country ?
    24 Are you still struggling to setup the Woocommerce Shipping Cost based on User Role and Destination Country ?
     22Do you want to show shipping methods based on user role?
     23Do you want to show shipping methods based on shipping country?
     24Are you still struggling to set up the Woocommerce Shipping Cost based on User Role and Destination Country ?
    2525
    2626Here's the solution for your requirement. Setup Flat Rate / Free Shipping or Shipping Cost using any third Party Plugin and Manage them Which Shipping Cost need to be shown to which user and for which country.
    2727
    2828= Features =
    29  * Manage WooCommerce Shipping Method based on User role.
    30  * Manage WooCommerce Shipping Method based on Country.
    31  * Manage Woocommerce Shipping Method based on User role and Destination Country.
    32  * Manage shipping method based on shipping method name or label
     29 * Display shipping methods based on user role
     30 * Display shipping methods based on shipping country
     31 * Option to hide all other shipping methods and shown only Free Shipping when Free Shipping is available during checkout
    3332
    3433== Installation ==
     
    4342== Frequently Asked Questions ==
    4443
     44= Compatibility? =
     45
     46Globally Compatible. It is compatible with all the shipping methods offered by WooCommerce and third party plugins.
     47
     48= How to display Free Shipping only? =
     49
     50Go to General section in plugin settings page.
     51Enable the plugin and under Hide shipping methods select option to Show Free Shipping Only, hide other shipping methods.
     52Note It's independent of rule matrix.
     53It will only work when Free Shipping is available during checkout.
     54
    4555= How to setup the plugin? =
    4656
     
    5161Woocommerce store info: Assume our store offer three shipping methods - Standard Delivery, Express Shipping, One Day Shipping.
    5262
    53 Case 1: I want to show One Day Shipping method to Administrator user role in USA.
     63Case 1: I want to show One Day Shipping method to Administrator user role in the USA.
    5464
    55 To acheive it add a new rule in Rules settings page.
     65To achieve it add a new rule in Rules settings page.
    5666* Select Administrator in User Role field.
    5767* Select United States in Countries field.
     
    6171* Now go to shop page add any product and recalculate the shipping cost by changing the address, Standard Delivery and Express Shipping method won't be shown.
    6272
    63 Case 2: I want to show Standard Delivery, Express Shipping method to Guest user role in USA.
     73Case 2: I want to show Standard Delivery, Express Shipping method to Guest user role in the USA.
    6474
    65 To acheive it add a new rule in Rules settings page.
     75To achieve it add a new rule in Rules settings page.
    6676* Select Guest in User Role field.
    6777* Select United States in Countries field.
     
    7686
    7787= Plugin not working after setting the plugin? =
    78 If you have done the plugin setup and you still don't see any change in cart/checkout page then please try to recalculate the shipping cost by changing the address because by default woocommerce will show you the cached shipping methods.
     88If you have done the plugin setup, and you still don't see any change in cart/checkout page then please try to recalculate the shipping cost by changing the address because
     89by default woocommerce will show you the cached shipping methods.
    7990
    8091= Sample Video =
     
    88993. Value of Shipping Method to hide
    891004. Shipping method hidden
    90 5. Multiple shipping method rule configuration for sigle user role
     1015. Multiple shipping method rule configuration for single user role
    911026. Shipping method hidden based on label / name
    92103
     
    114125 * Compatibility with WordPress 5.9
    115126 * Compatibility with WooCommerce 6.1.1
    116  * New option to hide shipping method based on shipping method name / title / lable
     127 * New option to hide shipping method based on shipping method name / title / label
    117128
    118129= 2.0.1 =
     
    124135 * Tested with WooCommerce 8.5.2
    125136
     137= 3.0.0 =
     138 * Feature to hide all the shipping methods, and show only free shipping method, when free shipping is available during checkout
     139 * Readme content change
     140 * Tested with WooCommerce 8.6.1
     141
    126142== Upgrade Notice ==
    127143
    128 = 2.0.1 =
    129  * Handled PHP compatibility issue
    130  * Tested with WordPress 6.4.3
    131  * Tested with WooCommerce 8.5.2
     144= 3.0.0 =
     145 * Feature to hide all the shipping methods, and show only free shipping method, when free shipping is available during checkout
     146 * Tested with WooCommerce 8.6.1
Note: See TracChangeset for help on using the changeset viewer.