Plugin Directory

Changeset 3372376


Ignore:
Timestamp:
10/03/2025 01:05:10 PM (5 months ago)
Author:
webwizardsdev
Message:

1.2.0 commit

Location:
b2bking-private-store-for-woocommerce/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • b2bking-private-store-for-woocommerce/trunk/b2bking.php

    r2971486 r3372376  
    55 * Plugin URI:        https://kingsplugins.com/woocommerce-wholesale/b2bking/
    66 * Description:       B2BKing is the ultimate plugin solution for B2B and Wholesale stores with 137+ features, handling everything from business registration, to wholesale pricing, catalog visibility, tax exemptions, and much more.
    7  * Version:           1.1.2
     7 * Version:           1.2.0
    88 * Author:            WebWizards
    99 * Author URI:        webwizards.dev
     
    1111 * Domain Path:       /languages
    1212 * WC requires at least: 5.0.0
    13  * WC tested up to: 8.1.0
     13 * WC tested up to: 10.2.1
    1414 */
    1515
     
    3838}
    3939
     40register_activation_hook(__FILE__, function() {
     41    // Check if B2BKing constants are defined
     42    if (defined('B2BKING_VERSION') || defined('B2BKING_DIR')) {
     43        wp_die(
     44            '<h3>B2BKing Pro is already active!</h3>' .
     45            '<p>B2BKing Pro includes all features from the Private Store plugin. There\'s no need to activate both.</p>' .
     46            '<p>Please use B2BKing Pro only to avoid conflicts.</p>',
     47            'Plugin Activation Stopped',
     48            ['back_link' => true]
     49        );
     50    }
     51});
     52
    4053add_action( 'before_woocommerce_init', function() {
    4154    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
  • b2bking-private-store-for-woocommerce/trunk/includes/class-b2bking.php

    r2619075 r3372376  
    1313            $public = new B2bkingpriv_Public();
    1414        }
     15
     16        add_action('plugins_loaded', function(){
     17
     18            // Only load if WooCommerce is activated
     19            if ( class_exists( 'woocommerce' ) ) {
     20
     21                // Check that plugin is enabled
     22                if ( get_option('b2bking_plugin_status_setting', 'disabled') !== 'disabled' ){
     23
     24                    /* Guest access restriction settings: */
     25                    // Hide prices
     26                    if (!is_user_logged_in()){
     27                        if (get_option('b2bking_guest_access_restriction_setting', 'hide_prices') === 'hide_prices'){   
     28                            add_filter( 'woocommerce_get_price_html', array($this, 'b2bking_hide_prices_guest_users'), 9999, 2 );
     29                            add_filter( 'woocommerce_variation_get_price_html', array($this, 'b2bking_hide_prices_guest_users'), 9999, 2 );
     30                            // Hide add to cart button as well / purchasable capabilities
     31                            add_filter( 'woocommerce_is_purchasable', array($this, 'b2bking_disable_purchasable_guest_users'));
     32                            add_filter( 'woocommerce_variation_is_purchasable', array($this, 'b2bking_disable_purchasable_guest_users'));
     33                        }
     34                    }
     35                }
     36            }
     37        });
    1538   
    1639    }
     
    2346    }
    2447
     48    function b2bking_hide_prices_guest_users( $price, $product ) {
     49        // if user is guest
     50        if (!is_user_logged_in()){
     51            return wp_kses(get_option('b2bking_hide_prices_guests_text_setting', esc_html__('Login to view prices','b2bking')), array('a' => array('href'  => array())));
     52        } else {
     53            return $price;
     54        }
     55    }
     56
     57    function b2bking_disable_purchasable_guest_users($purchasable){
     58        // if user is guest
     59        if (!is_user_logged_in()){
     60            return false;
     61        } else {
     62            return $purchasable;
     63        }
     64    }
     65
    2566}
    2667
  • b2bking-private-store-for-woocommerce/trunk/readme.txt

    r3269158 r3372376  
    99Tested up to: 6.8
    1010Requires PHP: 5.6.20
    11 Stable tag: 1.0.0
    12 Version: 1.1.0
     11Stable tag: 1.2.0
     12Version: 1.2.0
    1313License: GPLv2 or later
    1414License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.