create product
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
70 changed files
with
3005 additions
and
0 deletions
This diff is collapsed.
Click to expand it.
| 1 | --- | ||
| 2 | name: Bug report | ||
| 3 | about: Create a report to help us improve | ||
| 4 | |||
| 5 | --- | ||
| 6 | |||
| 7 | **Describe the bug** | ||
| 8 | A clear and concise description of what the bug is. | ||
| 9 | |||
| 10 | **To Reproduce** | ||
| 11 | Steps to reproduce the behavior: | ||
| 12 | 1. Go to '...' | ||
| 13 | 2. Click on '....' | ||
| 14 | 3. Scroll down to '....' | ||
| 15 | 4. See error | ||
| 16 | |||
| 17 | **Expected behavior** | ||
| 18 | A clear and concise description of what you expected to happen. | ||
| 19 | |||
| 20 | **Screenshots** | ||
| 21 | 1. Role Based Price For WooCommerce Settings | ||
| 22 | 2. WC Price Editor View (For the product which has the issue) | ||
| 23 | If applicable, add screenshots to help explain your problem. | ||
| 24 | |||
| 25 | **Software Versions** | ||
| 26 | 1. WordPress : | ||
| 27 | 2. WooCommerce : | ||
| 28 | 3. Role Based Price For WooCommerce : | ||
| 29 | |||
| 30 | **Desktop (please complete the following information):** | ||
| 31 | - OS: [e.g. iOS] | ||
| 32 | - Browser [e.g. chrome, safari] | ||
| 33 | - Version [e.g. 22] | ||
| 34 | |||
| 35 | **Smartphone (please complete the following information):** | ||
| 36 | - Device: [e.g. iPhone6] | ||
| 37 | - OS: [e.g. iOS8.1] | ||
| 38 | - Browser [e.g. stock browser, safari] | ||
| 39 | - Version [e.g. 22] | ||
| 40 | |||
| 41 | **Additional context** | ||
| 42 | Add any other context about the problem here. |
wp-content/plugins/woocommerce-role-based-price/.github/ISSUE_TEMPLATE/feature_request.md
0 → 100644
| 1 | --- | ||
| 2 | name: Feature request | ||
| 3 | about: Suggest an idea for this project | ||
| 4 | |||
| 5 | --- | ||
| 6 | |||
| 7 | **Is your feature request related to a problem? Please describe.** | ||
| 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
| 9 | |||
| 10 | **Describe the solution you'd like** | ||
| 11 | A clear and concise description of what you want to happen. | ||
| 12 | |||
| 13 | **Describe alternatives you've considered** | ||
| 14 | A clear and concise description of any alternative solutions or features you've considered. | ||
| 15 | |||
| 16 | **Additional context** | ||
| 17 | Add any other context or screenshots about the feature request here. |
| 1 | name: PHP CI/CD | ||
| 2 | |||
| 3 | env: | ||
| 4 | VS_WORKFLOW_TYPE: "php-cicd" | ||
| 5 | |||
| 6 | on: | ||
| 7 | push: | ||
| 8 | branches: | ||
| 9 | - master | ||
| 10 | - main | ||
| 11 | paths: | ||
| 12 | - '**.php' | ||
| 13 | |||
| 14 | jobs: | ||
| 15 | apigen_docs: | ||
| 16 | name: "ApiGen Docs" | ||
| 17 | runs-on: ubuntu-latest | ||
| 18 | steps: | ||
| 19 | - name: "📥 Fetching Repository Contents" | ||
| 20 | uses: actions/checkout@main | ||
| 21 | |||
| 22 | - name: "💾 Github Repository Metadata" | ||
| 23 | uses: varunsridharan/action-repository-meta@main | ||
| 24 | env: | ||
| 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 26 | |||
| 27 | - name: "💫 VS Utility" | ||
| 28 | uses: varunsridharan/action-vs-utility@main | ||
| 29 | |||
| 30 | - name: "⚡ Repository - Before Hook" | ||
| 31 | run: | | ||
| 32 | echo " " | ||
| 33 | if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then | ||
| 34 | echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" | ||
| 35 | sh $VS_BEFORE_HOOK_FILE_LOCATION | ||
| 36 | else | ||
| 37 | echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" | ||
| 38 | fi | ||
| 39 | echo " " | ||
| 40 | |||
| 41 | - name: "📚 Generating Code Documentation" | ||
| 42 | uses: varunsridharan/action-apigen@2.1 | ||
| 43 | env: | ||
| 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 45 | |||
| 46 | - name: "⚡ Repository - After Hook" | ||
| 47 | run: | | ||
| 48 | echo " " | ||
| 49 | if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then | ||
| 50 | echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" | ||
| 51 | sh $VS_AFTER_HOOK_FILE_LOCATION | ||
| 52 | else | ||
| 53 | echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" | ||
| 54 | fi | ||
| 55 | echo " " | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | name: Twitter Post On Release | ||
| 2 | |||
| 3 | env: | ||
| 4 | VS_WORKFLOW_TYPE: "twitter-post" | ||
| 5 | |||
| 6 | on: | ||
| 7 | release: | ||
| 8 | types: | ||
| 9 | - published | ||
| 10 | |||
| 11 | jobs: | ||
| 12 | twitter_post: | ||
| 13 | name: "🐦 Tweet" | ||
| 14 | runs-on: ubuntu-latest | ||
| 15 | steps: | ||
| 16 | - name: "📥 Fetching Repository Contents" | ||
| 17 | uses: actions/checkout@main | ||
| 18 | |||
| 19 | - name: "💾 Github Repository Metadata" | ||
| 20 | uses: varunsridharan/action-repository-meta@main | ||
| 21 | env: | ||
| 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 23 | |||
| 24 | - name: "💫 VS Utility" | ||
| 25 | uses: varunsridharan/action-vs-utility@main | ||
| 26 | env: | ||
| 27 | SVA_ONL_TOKEN: ${{ secrets.SVA_ONL_TOKEN }} | ||
| 28 | |||
| 29 | - name: "⚡ Repository - Before Hook" | ||
| 30 | run: | | ||
| 31 | echo " " | ||
| 32 | if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then | ||
| 33 | echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" | ||
| 34 | sh $VS_BEFORE_HOOK_FILE_LOCATION | ||
| 35 | else | ||
| 36 | echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" | ||
| 37 | fi | ||
| 38 | echo " " | ||
| 39 | |||
| 40 | - name: "🚀 Publishing Tweet 🐦 " | ||
| 41 | uses: m1ner79/Github-Twittction@master | ||
| 42 | with: | ||
| 43 | twitter_status: ${{ env.TWITTER_STATUS }} | ||
| 44 | twitter_consumer_key: ${{ secrets.TWITTER_API_KEY }} | ||
| 45 | twitter_consumer_secret: ${{ secrets.TWITTER_API_SECRET_KEY }} | ||
| 46 | twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN }} | ||
| 47 | twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_SECRET_TOKEN }} | ||
| 48 | |||
| 49 | - name: "⚡ Repository - After Hook" | ||
| 50 | run: | | ||
| 51 | echo " " | ||
| 52 | if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then | ||
| 53 | echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" | ||
| 54 | sh $VS_AFTER_HOOK_FILE_LOCATION | ||
| 55 | else | ||
| 56 | echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" | ||
| 57 | fi | ||
| 58 | echo " " | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/.github/workflows/wordpress.org-release.yml
0 → 100644
| 1 | name: "Release - WordPress.org" | ||
| 2 | |||
| 3 | env: | ||
| 4 | DIST_LOCATION: "./dist/" | ||
| 5 | VS_WORKFLOW_TYPE: "wordpress-org-release" | ||
| 6 | |||
| 7 | on: | ||
| 8 | release: | ||
| 9 | types: | ||
| 10 | - published | ||
| 11 | |||
| 12 | jobs: | ||
| 13 | publish-wordpress-org: | ||
| 14 | name: "🚀 WordPress Publisher" | ||
| 15 | runs-on: ubuntu-latest | ||
| 16 | steps: | ||
| 17 | - name: "📥 Fetching Repository Contents" | ||
| 18 | uses: actions/checkout@main | ||
| 19 | |||
| 20 | - name: "💾 Github Repository Metadata" | ||
| 21 | uses: varunsridharan/action-repository-meta@main | ||
| 22 | env: | ||
| 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 24 | |||
| 25 | - name: "💫 VS Utility" | ||
| 26 | uses: varunsridharan/action-vs-utility@main | ||
| 27 | |||
| 28 | - name: "⚡ Repository - Before Hook" | ||
| 29 | run: | | ||
| 30 | echo " " | ||
| 31 | if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then | ||
| 32 | echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" | ||
| 33 | sh $VS_BEFORE_HOOK_FILE_LOCATION | ||
| 34 | else | ||
| 35 | echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" | ||
| 36 | fi | ||
| 37 | echo " " | ||
| 38 | |||
| 39 | - name: "💽 Installing Composer" | ||
| 40 | uses: g-actions/composer-action@main | ||
| 41 | with: | ||
| 42 | command: install --no-dev | ||
| 43 | |||
| 44 | - name: "🚀 Publishing Release" | ||
| 45 | uses: varunsridharan/action-wp-org-deploy@main | ||
| 46 | with: | ||
| 47 | WORDPRESS_PASSWORD: ${{ secrets.WP_PASSWORD }} | ||
| 48 | WORDPRESS_USERNAME: ${{ secrets.WP_USERNAME }} | ||
| 49 | SLUG: ${{ env.GITHUB_REPOSITORY_NAME }} | ||
| 50 | IGNORE_FILE: ${{ env.WORDPRESS_DIST_IGNORE }} | ||
| 51 | ASSETS_IGNORE_FILE: ${{ env.WORDPRESS_ASSETS_DIST_IGNORE }} | ||
| 52 | DIST_LOCATION: ${{ env.DIST_LOCATION }} | ||
| 53 | |||
| 54 | - name: "📦 Upload ZIP To Release in Github" | ||
| 55 | uses: Roang-zero1/github-upload-release-artifacts-action@master | ||
| 56 | with: | ||
| 57 | args: ${{ env.DIST_LOCATION }} | ||
| 58 | env: | ||
| 59 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 60 | |||
| 61 | - name: "⚡ Repository - After Hook" | ||
| 62 | run: | | ||
| 63 | echo " " | ||
| 64 | if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then | ||
| 65 | echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" | ||
| 66 | sh $VS_AFTER_HOOK_FILE_LOCATION | ||
| 67 | else | ||
| 68 | echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" | ||
| 69 | fi | ||
| 70 | echo " " | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin Main File | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/core | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if ( ! defined( 'WPINC' ) ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price { | ||
| 15 | protected static $_instance = null; | ||
| 16 | protected static $functions = null; | ||
| 17 | protected static $admin = null; # Required Plugin Class Instance | ||
| 18 | protected static $settings = null; # Required Plugin Class Instance | ||
| 19 | protected static $frontend = null; # Required Plugin Class Instance | ||
| 20 | protected static $shortcode_handler = null; # Required Plugin Class Instance | ||
| 21 | public $version = '3.3.5'; # Required Plugin Class INstance | ||
| 22 | public $plugin_vars = array(); # Required Plugin Class INstance | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Class Constructor | ||
| 26 | */ | ||
| 27 | public function __construct() { | ||
| 28 | $this->define_constant(); | ||
| 29 | $this->load_required_files(); | ||
| 30 | $this->init_hooks(); | ||
| 31 | do_action( 'wc_rbp_loaded' ); | ||
| 32 | } | ||
| 33 | |||
| 34 | /** | ||
| 35 | * Define Required Constant | ||
| 36 | */ | ||
| 37 | private function define_constant() { | ||
| 38 | $this->define( 'WC_RBP_NAME', 'Role Based Price For WooCommerce' ); # Plugin Name | ||
| 39 | $this->define( 'WC_RBP_SLUG', 'woocommerce-role-based-price' ); # Plugin Slug | ||
| 40 | $this->define( 'WC_RBP_TXT', 'woocommerce-role-based-price' ); #plugin lang Domain | ||
| 41 | $this->define( 'WC_RBP_DB', 'wc_rbp_' ); | ||
| 42 | $this->define( 'WC_RBP_V', $this->version ); # Plugin Version | ||
| 43 | |||
| 44 | $this->define( 'WC_RBP_LANGUAGE_PATH', WC_RBP_PATH . 'languages' ); # Plugin Language Folder | ||
| 45 | $this->define( 'WC_RBP_ADMIN', WC_RBP_INC . 'admin/' ); # Plugin Admin Folder | ||
| 46 | $this->define( 'WC_RBP_SETTINGS', WC_RBP_ADMIN . 'settings/' ); # Plugin Settings Folder | ||
| 47 | $this->define( 'WC_RBP_PLUGIN', WC_RBP_PATH . 'plugins/' ); | ||
| 48 | |||
| 49 | $this->define( 'WC_RBP_URL', plugins_url( '', __FILE__ ) . '/' ); # Plugin URL | ||
| 50 | $this->define( 'WC_RBP_PLUGIN_URL', WC_RBP_URL . 'plugins/' ); # Plugin URL | ||
| 51 | $this->define( 'WC_RBP_CSS', WC_RBP_URL . 'includes/css/' ); # Plugin CSS URL | ||
| 52 | $this->define( 'WC_RBP_IMG', WC_RBP_URL . 'includes/img/' ); # Plugin IMG URL | ||
| 53 | $this->define( 'WC_RBP_JS', WC_RBP_URL . 'includes/js/' ); # Plugin JS URL | ||
| 54 | } | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Define constant if not already set | ||
| 58 | * | ||
| 59 | * @param string $name | ||
| 60 | * @param string|bool $value | ||
| 61 | */ | ||
| 62 | protected function define( $key, $value ) { | ||
| 63 | if ( ! defined( $key ) ) { | ||
| 64 | define( $key, $value ); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | /** | ||
| 69 | * Loads Required Plugins For Plugin | ||
| 70 | */ | ||
| 71 | private function load_required_files() { | ||
| 72 | $this->load_files( WC_RBP_INC . 'abstract-*.php' ); | ||
| 73 | $this->load_files( WC_RBP_INC . 'helpers/class-admin-notice.php' ); | ||
| 74 | $this->load_files( WC_RBP_INC . 'class-*.php' ); | ||
| 75 | $this->load_files( WC_RBP_ADMIN . 'settings_framework/class-wp-plugin-options.php' ); | ||
| 76 | $this->load_files( WC_RBP_ADMIN . 'settings_framework/class-wp-*.php' ); | ||
| 77 | |||
| 78 | if ( wc_rbp_is_request( 'admin' ) ) { | ||
| 79 | $this->load_files( WC_RBP_ADMIN . 'class-*.php' ); | ||
| 80 | } | ||
| 81 | |||
| 82 | do_action( 'wc_rbp_before_addons_load' ); | ||
| 83 | $this->load_addons(); | ||
| 84 | |||
| 85 | } | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Loads Files Based On Give Path & regex | ||
| 89 | */ | ||
| 90 | protected function load_files( $path, $type = 'require' ) { | ||
| 91 | foreach ( glob( $path ) as $files ) { | ||
| 92 | if ( $type == 'require' ) { | ||
| 93 | require_once( $files ); | ||
| 94 | } elseif ( $type == 'include' ) { | ||
| 95 | include_once( $files ); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | public function load_addons() { | ||
| 101 | $addons = wc_rbp_get_active_addons(); | ||
| 102 | if ( ! empty( $addons ) ) { | ||
| 103 | foreach ( $addons as $addon ) { | ||
| 104 | if ( apply_filters( 'wc_rbp_load_addon', true, $addon ) ) { | ||
| 105 | do_action( 'wc_rbp_before_' . $addon . '_addon_load' ); | ||
| 106 | $this->load_addon( $addon ); | ||
| 107 | do_action( 'wc_rbp_after_' . $addon . '_addon_load' ); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | public function load_addon( $file ) { | ||
| 114 | $other_file = apply_filters( 'wc_rbp_addon_file_location', $file ); | ||
| 115 | |||
| 116 | if ( file_exists( WC_RBP_PLUGIN . $file ) ) { | ||
| 117 | $this->load_files( WC_RBP_PLUGIN . $file ); | ||
| 118 | } elseif ( file_exists( $other_file ) ) { | ||
| 119 | $this->load_files( $other_file ); | ||
| 120 | } else { | ||
| 121 | if ( has_action( 'wc_rbp_addon_' . $file . '_load' ) ) { | ||
| 122 | do_action( 'wc_rbp_addon_' . $file . '_load' ); | ||
| 123 | } else { | ||
| 124 | wc_rbp_deactivate_addon( $file ); | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | } | ||
| 129 | |||
| 130 | public function init_hooks() { | ||
| 131 | add_action( 'plugins_loaded', array( $this, 'after_plugins_loaded' ) ); | ||
| 132 | add_filter( 'load_textdomain_mofile', array( $this, 'load_plugin_mo_files' ), 10, 2 ); | ||
| 133 | add_action( 'init', array( $this, 'init' ), 0 ); | ||
| 134 | } | ||
| 135 | |||
| 136 | /** | ||
| 137 | * Creates or returns an instance of this class. | ||
| 138 | */ | ||
| 139 | public static function get_instance() { | ||
| 140 | if ( null == self::$_instance ) { | ||
| 141 | self::$_instance = new self; | ||
| 142 | } | ||
| 143 | return self::$_instance; | ||
| 144 | } | ||
| 145 | |||
| 146 | # Returns Plugin's Functions Instance | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Throw error on object clone. | ||
| 150 | * | ||
| 151 | * Cloning instances of the class is forbidden. | ||
| 152 | * | ||
| 153 | * @since 1.0 | ||
| 154 | * @return void | ||
| 155 | */ | ||
| 156 | public function __clone() { | ||
| 157 | _doing_it_wrong( __FUNCTION__, __( 'Cloning instances of the class is forbidden.', WC_RBP_TXT ), WC_RBP_V ); | ||
| 158 | } | ||
| 159 | |||
| 160 | # Returns Plugin's Functions Instance | ||
| 161 | |||
| 162 | /** | ||
| 163 | * Disable unserializing of the class | ||
| 164 | * | ||
| 165 | * Unserializing instances of the class is forbidden. | ||
| 166 | * | ||
| 167 | * @since 1.0 | ||
| 168 | * @return void | ||
| 169 | */ | ||
| 170 | public function __wakeup() { | ||
| 171 | _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of the class is forbidden.', WC_RBP_TXT ), WC_RBP_V ); | ||
| 172 | } | ||
| 173 | |||
| 174 | # Returns Plugin's Settings Instance | ||
| 175 | |||
| 176 | /** | ||
| 177 | * Inits loaded Class | ||
| 178 | */ | ||
| 179 | public function init() { | ||
| 180 | do_action( 'wc_rbp_before_init' ); | ||
| 181 | |||
| 182 | self::$functions = new WooCommerce_Role_Based_Price_Functions; | ||
| 183 | self::$settings = new WooCommerce_Role_Based_Price_Settings_Framework; | ||
| 184 | self::$shortcode_handler = new WooCommerce_Role_Based_Price_Shortcode_Handler; | ||
| 185 | |||
| 186 | if ( wc_rbp_is_request( 'admin' ) ) { | ||
| 187 | self::$admin = new WooCommerce_Role_Based_Price_Admin; | ||
| 188 | } else { | ||
| 189 | self::$frontend = new WooCommerce_Role_Based_Price_Product_Pricing; | ||
| 190 | } | ||
| 191 | |||
| 192 | do_action( 'wc_rbp_init' ); | ||
| 193 | } | ||
| 194 | |||
| 195 | # Returns Plugin's Admin Instance | ||
| 196 | |||
| 197 | public function func() { | ||
| 198 | return self::$functions; | ||
| 199 | } | ||
| 200 | |||
| 201 | public function frontend() { | ||
| 202 | return self::$frontend; | ||
| 203 | } | ||
| 204 | |||
| 205 | public function settings() { | ||
| 206 | return self::$settings; | ||
| 207 | } | ||
| 208 | |||
| 209 | public function admin() { | ||
| 210 | return self::$admin; | ||
| 211 | } | ||
| 212 | |||
| 213 | /** | ||
| 214 | * Set Plugin Text Domain | ||
| 215 | */ | ||
| 216 | public function after_plugins_loaded() { | ||
| 217 | load_plugin_textdomain( WC_RBP_TXT, false, WC_RBP_LANGUAGE_PATH ); | ||
| 218 | } | ||
| 219 | |||
| 220 | /** | ||
| 221 | * load translated mo file based on wp settings | ||
| 222 | */ | ||
| 223 | public function load_plugin_mo_files( $mofile, $domain ) { | ||
| 224 | if ( WC_RBP_TXT === $domain ) { | ||
| 225 | return WC_RBP_LANGUAGE_PATH . '/' . get_locale() . '.mo'; | ||
| 226 | } | ||
| 227 | return $mofile; | ||
| 228 | } | ||
| 229 | |||
| 230 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * | ||
| 4 | * Addons Handler | ||
| 5 | * | ||
| 6 | * @link https://codecanyon.net/item/advanced-product-reviews-for-woocommerce/15385857 | ||
| 7 | * @package APRWC | ||
| 8 | * @subpackage APRWC/FrontEnd | ||
| 9 | * @since 2.0 | ||
| 10 | */ | ||
| 11 | if( ! defined('WPINC') ) { | ||
| 12 | die; | ||
| 13 | } | ||
| 14 | |||
| 15 | class WooCommerce_Role_Based_Price_Addon_Handler { | ||
| 16 | |||
| 17 | public function __construct() { | ||
| 18 | add_filter('wc_rbp_addon_sections', array( $this, 'register_section' )); | ||
| 19 | add_filter('wc_rbp_addon_fields', array( $this, 'register_fields' )); | ||
| 20 | |||
| 21 | add_action('wp_enqueue_scripts', array( $this, 'frontend_style' )); | ||
| 22 | add_action('wp_enqueue_scripts', array( $this, 'frontend_script' )); | ||
| 23 | |||
| 24 | if( is_admin() ) { | ||
| 25 | add_action('wc_rbp_admin_styles', array( $this, 'admin_style' )); | ||
| 26 | add_action('wc_rbp_admin_scripts', array( $this, 'admin_script' )); | ||
| 27 | } | ||
| 28 | |||
| 29 | add_action('wc_rbp_loaded', array( $this, 'init_class' )); | ||
| 30 | } | ||
| 31 | |||
| 32 | public function register_section($settings_section) { | ||
| 33 | return $settings_section; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function register_fields($settings_fields) { | ||
| 37 | return $settings_fields; | ||
| 38 | } | ||
| 39 | |||
| 40 | public function init_class() { | ||
| 41 | } | ||
| 42 | |||
| 43 | public function admin_style($screen = '') { | ||
| 44 | } | ||
| 45 | |||
| 46 | public function admin_script($screen = '') { | ||
| 47 | } | ||
| 48 | |||
| 49 | public function frontend_style() { | ||
| 50 | } | ||
| 51 | |||
| 52 | public function frontend_script() { | ||
| 53 | } | ||
| 54 | |||
| 55 | public function addon_path($file = __DIR__) { | ||
| 56 | return plugin_dir_path($file); | ||
| 57 | } | ||
| 58 | |||
| 59 | public function addon_url($file = __FILE__) { | ||
| 60 | return plugin_dir_url($file); | ||
| 61 | } | ||
| 62 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin's Admin code | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/Admin | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if ( ! defined( 'WPINC' ) ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price_Admin { | ||
| 15 | |||
| 16 | /** | ||
| 17 | * Initialize the class and set its properties. | ||
| 18 | * | ||
| 19 | * @since 0.1 | ||
| 20 | */ | ||
| 21 | public function __construct() { | ||
| 22 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ), 99 ); | ||
| 23 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | ||
| 24 | add_action( 'admin_init', array( $this, 'admin_init' ) ); | ||
| 25 | add_filter( 'woocommerce_screen_ids', array( $this, 'set_wc_screen_ids' ), 99 ); | ||
| 26 | add_filter( 'plugin_row_meta', array( $this, 'plugin_row_links' ), 10, 2 ); | ||
| 27 | add_filter( 'plugin_action_links_' . WC_RBP_FILE, array( $this, 'plugin_action_links' ), 10, 10 ); | ||
| 28 | //add_action( 'admin_menu',array($this,'add_welcome_menu')); | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | public function set_wc_screen_ids( $screens ) { | ||
| 33 | $screen = $screens; | ||
| 34 | $screen[] = 'woocommerce_page_woocommerce-role-based-price-settings'; | ||
| 35 | $screen[] = 'product_page_rbp_global_addons'; | ||
| 36 | return $screen; | ||
| 37 | } | ||
| 38 | |||
| 39 | /** | ||
| 40 | * Inits Admin Sttings | ||
| 41 | */ | ||
| 42 | public function admin_init() { | ||
| 43 | //$this->handle_welcome_page(); | ||
| 44 | |||
| 45 | |||
| 46 | new WooCommerce_Role_Based_Price_Admin_Ajax_Handler; | ||
| 47 | new WooCommerce_Role_Based_Price_Addons; | ||
| 48 | } | ||
| 49 | |||
| 50 | public function handle_welcome_page() { | ||
| 51 | if ( ! get_transient( '_welcome_redirect_wcrbp' ) ) { | ||
| 52 | return; | ||
| 53 | } | ||
| 54 | |||
| 55 | delete_transient( '_welcome_redirect_wcrbp' ); | ||
| 56 | |||
| 57 | if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | ||
| 58 | return; | ||
| 59 | } | ||
| 60 | wp_safe_redirect( add_query_arg( array( 'page' => 'wcrbp_welcome_page' ), admin_url( 'plugins.php' ) ) ); | ||
| 61 | } | ||
| 62 | |||
| 63 | public function add_welcome_menu() { | ||
| 64 | if ( ! get_transient( '_welcome_redirect_wcrbp' ) ) { | ||
| 65 | //return; | ||
| 66 | } | ||
| 67 | |||
| 68 | if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | ||
| 69 | return; | ||
| 70 | } | ||
| 71 | |||
| 72 | add_submenu_page( 'plugins.php', __( 'Role Based Price For WooCommerce Welcome Page', 'WPW' ), __( 'Role Based Price For WooCommerce Welcome Page', 'WPW' ), 'read', 'wcrbp_welcome_page', array( | ||
| 73 | $this, | ||
| 74 | 'wcrbp_welcome_page_content', | ||
| 75 | ) ); | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | public function wcrbp_welcome_page_content() { | ||
| 80 | include( WC_RBP_ADMIN . 'views/plugin-welcome-page.php' ); | ||
| 81 | } | ||
| 82 | |||
| 83 | /** | ||
| 84 | * Register the stylesheets for the admin area. | ||
| 85 | */ | ||
| 86 | public function enqueue_styles() { | ||
| 87 | $current_screen = wc_rbp_current_screen(); | ||
| 88 | $addon_url = admin_url( 'admin-ajax.php?action=wc_rbp_addon_custom_css' ); | ||
| 89 | |||
| 90 | wp_register_style( WC_RBP_SLUG . '_backend_style', WC_RBP_CSS . 'backend.css', array(), WC_RBP_V, 'all' ); | ||
| 91 | wp_register_style( WC_RBP_SLUG . '_addons_style', $addon_url, array(), WC_RBP_V, 'all' ); | ||
| 92 | wp_register_style( WC_RBP_SLUG . '_settings_selectize_style', WC_RBP_CSS . 'selectize.js.css', array(), WC_RBP_V, 'all' ); | ||
| 93 | wp_register_style( WC_RBP_SLUG . '_tabs_style', WC_RBP_CSS . 'tabs.css', array(), WC_RBP_V, 'all' ); | ||
| 94 | |||
| 95 | wp_enqueue_style( WC_RBP_SLUG . '_backend_style' ); | ||
| 96 | wp_enqueue_style( WC_RBP_SLUG . '_addons_style' ); | ||
| 97 | |||
| 98 | |||
| 99 | if ( 'woocommerce_page_woocommerce-role-based-price-settings' == $current_screen ) { | ||
| 100 | wp_enqueue_style( WC_RBP_SLUG . '_settings_selectize_style' ); | ||
| 101 | add_thickbox(); | ||
| 102 | } | ||
| 103 | |||
| 104 | if ( 'product' == $current_screen ) { | ||
| 105 | wp_enqueue_style( WC_RBP_SLUG . '_tabs_style' ); | ||
| 106 | wp_enqueue_style( WC_RBP_SLUG . '_settings_selectize_style' ); | ||
| 107 | } | ||
| 108 | |||
| 109 | do_action( 'wc_rbp_admin_styles', $current_screen ); | ||
| 110 | } | ||
| 111 | |||
| 112 | |||
| 113 | /** | ||
| 114 | * Register the JavaScript for the admin area. | ||
| 115 | */ | ||
| 116 | public function enqueue_scripts() { | ||
| 117 | $current_screen = wc_rbp_current_screen(); | ||
| 118 | |||
| 119 | $addon_url = admin_url( 'admin-ajax.php?action=wc_rbp_addon_custom_js' ); | ||
| 120 | |||
| 121 | wp_register_script( WC_RBP_SLUG . '_backend_script', WC_RBP_JS . 'backend.js', array( 'jquery' ), WC_RBP_V, false ); | ||
| 122 | wp_register_script( WC_RBP_SLUG . '_addons_script', $addon_url, array( 'jquery' ), WC_RBP_V, false ); | ||
| 123 | wp_register_script( WC_RBP_SLUG . '_settings_selectize.js', WC_RBP_JS . 'selectize.js', array( 'jquery' ), WC_RBP_V, false ); | ||
| 124 | wp_register_script( WC_RBP_SLUG . '_settings_checkbox.js', WC_RBP_JS . 'checkbox.js', array( 'jquery' ), WC_RBP_V, false ); | ||
| 125 | wp_register_script( WC_RBP_SLUG . '_settings_js', WC_RBP_JS . 'settings-page.js', array( | ||
| 126 | 'jquery', | ||
| 127 | WC_RBP_SLUG . '_settings_selectize.js', | ||
| 128 | ), WC_RBP_V, false ); | ||
| 129 | wp_register_script( WC_RBP_SLUG . '_settings_checkbox.js', WC_RBP_JS . 'checkbox.js', array( 'jquery' ), WC_RBP_V, false ); | ||
| 130 | wp_register_script( WC_RBP_SLUG . '_jquery-tabs-script', WC_RBP_JS . 'tabs.js', array( 'jquery' ), WC_RBP_V, false ); | ||
| 131 | |||
| 132 | wp_enqueue_script( WC_RBP_SLUG . '_backend_script', WC_RBP_JS . 'backend.js', array( 'jquery' ), WC_RBP_V, false ); | ||
| 133 | |||
| 134 | |||
| 135 | if ( in_array( $current_screen, wc_rbp_get_screen_ids() ) ) { | ||
| 136 | } | ||
| 137 | |||
| 138 | if ( 'woocommerce_page_woocommerce-role-based-price-settings' == $current_screen ) { | ||
| 139 | wp_enqueue_script( WC_RBP_SLUG . '_settings_selectize.js' ); | ||
| 140 | wp_enqueue_script( WC_RBP_SLUG . '_settings_checkbox.js' ); | ||
| 141 | wp_enqueue_script( WC_RBP_SLUG . '_settings_js' ); | ||
| 142 | |||
| 143 | $msg = '<h3>' . __( 'Thanks For Your Continued Support For %1$s' ) . '</h3>'; | ||
| 144 | $msg .= __( 'We Are Already In A Process For Created Version 4.0 For This Plugin' ); | ||
| 145 | $msg .= '<br/><br/><a href="https://forms.gle/waxC4Mm9SZFWuq3A8" class="button button-secondary">' . __( 'Join Newsletter / Request Beta Access' ) . '</a>'; | ||
| 146 | $msg = sprintf( $msg, WC_RBP_NAME ); | ||
| 147 | wc_rbp_admin_update( $msg, 1, array(), array() ); | ||
| 148 | } | ||
| 149 | |||
| 150 | if ( 'product' == $current_screen ) { | ||
| 151 | wp_enqueue_script( WC_RBP_SLUG . '_settings_checkbox.js' ); | ||
| 152 | wp_enqueue_script( WC_RBP_SLUG . '_jquery-tabs-script' ); | ||
| 153 | wp_enqueue_script( WC_RBP_SLUG . '_jquery-product-script' ); | ||
| 154 | wp_enqueue_script( WC_RBP_SLUG . '_settings_selectize.js' ); | ||
| 155 | } | ||
| 156 | |||
| 157 | do_action( 'wc_rbp_admin_scripts', $current_screen ); | ||
| 158 | |||
| 159 | wp_enqueue_script( WC_RBP_SLUG . '_addons_script', $addon_url, array( 'jquery' ), WC_RBP_V, false ); | ||
| 160 | } | ||
| 161 | |||
| 162 | |||
| 163 | /** | ||
| 164 | * Adds Some Plugin Options | ||
| 165 | * | ||
| 166 | * @param array $plugin_meta | ||
| 167 | * @param string $plugin_file | ||
| 168 | * | ||
| 169 | * @return array | ||
| 170 | * @since 0.11 | ||
| 171 | */ | ||
| 172 | public function plugin_action_links( $action, $file, $plugin_meta, $status ) { | ||
| 173 | $url = admin_url( 'admin.php?page=woocommerce-role-based-price-settings' ); | ||
| 174 | $addonurl = admin_url( 'admin.php?page=woocommerce-role-based-price-settings&tab=wcrbpaddons' ); | ||
| 175 | |||
| 176 | $actions[] = sprintf( '<a href="%s">%s</a>', $url, __( 'Settings', WC_RBP_TXT ) ); | ||
| 177 | $actions[] = sprintf( '<a href="%s">%s</a>', $addonurl, __( 'Add-ons', WC_RBP_TXT ) ); | ||
| 178 | |||
| 179 | $action = array_merge( $actions, $action ); | ||
| 180 | return $action; | ||
| 181 | } | ||
| 182 | |||
| 183 | /** | ||
| 184 | * Adds Some Plugin Options | ||
| 185 | * | ||
| 186 | * @param array $plugin_meta | ||
| 187 | * @param string $plugin_file | ||
| 188 | * | ||
| 189 | * @return array | ||
| 190 | * @since 0.11 | ||
| 191 | */ | ||
| 192 | public function plugin_row_links( $plugin_meta, $plugin_file ) { | ||
| 193 | if ( WC_RBP_FILE == $plugin_file ) { | ||
| 194 | $plugin_meta[] = sprintf( '<a href="%s">%s</a>', '#', __( 'Docs', WC_RBP_TXT ) ); | ||
| 195 | $plugin_meta[] = sprintf( '<a href="%s">%s</a>', 'https://github.com/varunsridharan/woocommerce-role-based-price', __( 'View On Github', WC_RBP_TXT ) ); | ||
| 196 | $plugin_meta[] = sprintf( '<a href="%s">%s</a>', 'https://github.com/varunsridharan/woocommerce-role-based-price/issues', __( 'Report Issue', WC_RBP_TXT ) ); | ||
| 197 | $plugin_meta[] = sprintf( '♥ <a href="%s">%s</a>', 'https://www.paypal.me/varunsridharan23', __( 'Donate', WC_RBP_TXT ) ); | ||
| 198 | $plugin_meta[] = sprintf( '<a href="%s">%s</a>', 'http://varunsridharan.in/plugin-support/', __( 'Contact Author', WC_RBP_TXT ) ); | ||
| 199 | } | ||
| 200 | return $plugin_meta; | ||
| 201 | } | ||
| 202 | } |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * The admin-specific functionality of the plugin. | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/Admin | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if( ! defined('WPINC') ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price_Admin_Ajax_Handler { | ||
| 15 | |||
| 16 | public function __construct() { | ||
| 17 | add_action('wp_ajax_wc_rbp_clear_variation_cache', array( $this, 'clear_variation_cache' )); | ||
| 18 | add_action('wp_ajax_wc_rbp_save_product_prices', array( $this, 'save_product_rbp_price' )); | ||
| 19 | add_action('wp_ajax_nopriv_wc_rbp_addon_custom_css', array( $this, 'render_addon_css' )); | ||
| 20 | add_action('wp_ajax_wc_rbp_addon_custom_css', array( $this, 'render_addon_css' )); | ||
| 21 | add_action('wp_ajax_nopriv_wc_rbp_addon_custom_js', array( $this, 'render_addon_js' )); | ||
| 22 | add_action('wp_ajax_wc_rbp_addon_custom_js', array( $this, 'render_addon_js' )); | ||
| 23 | |||
| 24 | add_action('wp_ajax_wc_rbp_metabox_refersh', array( $this, 'refresh_metabox' )); | ||
| 25 | } | ||
| 26 | |||
| 27 | public function clear_variation_cache() { | ||
| 28 | if( ! isset($_REQUEST['post_id']) ) { | ||
| 29 | wp_send_json_error(__('Invalid Product ID', WC_RBP_TXT)); | ||
| 30 | } | ||
| 31 | $id = sanitize_text_field($_REQUEST['post_id']); | ||
| 32 | |||
| 33 | $parent = wp_get_post_parent_id($id); | ||
| 34 | if( $parent !== FALSE ) { | ||
| 35 | $allowed_roles = array_keys(wc_rbp_get_user_roles_selectbox()); | ||
| 36 | foreach( $allowed_roles as $role ) { | ||
| 37 | wc_rbp_delete_variation_data($id, $role); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | wp_send_json_success(array( __("Success") )); | ||
| 42 | } | ||
| 43 | |||
| 44 | public function refresh_metabox() { | ||
| 45 | if( ! isset($_REQUEST['pid']) ) { | ||
| 46 | wp_send_json_error(__('Invalid Product ID', WC_RBP_TXT)); | ||
| 47 | } | ||
| 48 | |||
| 49 | if( ! isset($_REQUEST['parentID']) ) { | ||
| 50 | wp_send_json_error(__('Invalid Product ID', WC_RBP_TXT)); | ||
| 51 | } | ||
| 52 | |||
| 53 | $id = sanitize_text_field($_REQUEST['pid']); | ||
| 54 | $parentid = sanitize_text_field($_REQUEST['parentID']); | ||
| 55 | $metabox = new WooCommerce_Role_Based_Price_Product_Metabox; | ||
| 56 | ob_start(); | ||
| 57 | //$metabox->generate_variation_selectbox($parentid,$id); | ||
| 58 | $metabox->render_price_editor_metabox($id); | ||
| 59 | $content = ob_get_contents(); | ||
| 60 | ob_end_clean(); | ||
| 61 | wp_send_json_success($content); | ||
| 62 | wp_die(); | ||
| 63 | } | ||
| 64 | |||
| 65 | public function render_addon_css() { | ||
| 66 | header('Content-Type: text/css'); | ||
| 67 | do_action('wc_rbp_addon_styles'); | ||
| 68 | wp_die(); | ||
| 69 | } | ||
| 70 | |||
| 71 | public function render_addon_js() { | ||
| 72 | header('Content-Type: text/javascript'); | ||
| 73 | do_action('wc_rbp_addon_scripts'); | ||
| 74 | wp_die(); | ||
| 75 | } | ||
| 76 | |||
| 77 | public function save_product_rbp_price() { | ||
| 78 | $is_verifyed_nounce = wp_verify_nonce($_POST['wc_rbp_nounce'], 'wc_rbp_save_product_prices'); | ||
| 79 | $error = array(); | ||
| 80 | $type = isset($_POST['type']) ? $_POST['type'] : 'default'; | ||
| 81 | $success = array( 'hidden_fields' => wc_rbp_get_editor_fields($type) ); | ||
| 82 | $posted_values = $_POST; | ||
| 83 | |||
| 84 | if( $is_verifyed_nounce ) { | ||
| 85 | do_action_ref_array('wc_rbp_product_save_' . $type, array( &$posted_values, &$success, &$error )); | ||
| 86 | } else { | ||
| 87 | $error['html'] = '<h3>' . __("Unable To Process Your Request Please Try Again later", WC_RBP_TXT) . '</h3>'; | ||
| 88 | } | ||
| 89 | |||
| 90 | if( empty($error) ) { | ||
| 91 | wp_send_json_success($success); | ||
| 92 | } else { | ||
| 93 | $error['hidden_fields'] = wc_rbp_get_editor_fields($type); | ||
| 94 | wp_send_json_error($error); | ||
| 95 | } | ||
| 96 | wp_die(); | ||
| 97 | } | ||
| 98 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * The admin-specific functionality of the plugin. | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/Admin | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if( ! defined('WPINC') ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price_Admin_Sample_Class { | ||
| 15 | |||
| 16 | public function __construct() { | ||
| 17 | |||
| 18 | } | ||
| 19 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | class WooCommerce_Role_Based_Price_Product_Metabox { | ||
| 4 | |||
| 5 | public function __construct() { | ||
| 6 | add_action('add_meta_boxes_product', array( $this, 'add_metabox' )); | ||
| 7 | } | ||
| 8 | |||
| 9 | public function add_metabox($post) { | ||
| 10 | add_meta_box('wc-rbp-product-editor', __('Role Based Price For WooCommerce Editor', WC_RBP_TXT), array( | ||
| 11 | $this, | ||
| 12 | 'render_price_editor_metabox', | ||
| 13 | ), 'product', 'advanced', 'high'); | ||
| 14 | } | ||
| 15 | |||
| 16 | public function render_price_editor_metabox($post) { | ||
| 17 | if( is_object($post) ) { | ||
| 18 | $id = $post->ID; | ||
| 19 | } else { | ||
| 20 | $id = $post; | ||
| 21 | } | ||
| 22 | |||
| 23 | $prod = NULL; | ||
| 24 | $prodType = $this->get_post_type($id); | ||
| 25 | |||
| 26 | $url = admin_url('admin-ajax.php?action=wc_rbp_save_product_prices'); | ||
| 27 | $render_info = '<div class="wc-rbp-metabox-container" method="POST" action="' . $url . '" > '; | ||
| 28 | $render_info .= wc_rbp_get_ajax_overlay(); | ||
| 29 | |||
| 30 | $this->allowed_roles = wc_rbp_allowed_roles(); | ||
| 31 | $this->registered_roles = wc_rbp_get_wp_roles(); | ||
| 32 | |||
| 33 | $args = array(); | ||
| 34 | $args['render_default'] = TRUE; | ||
| 35 | $args['html'] = ''; | ||
| 36 | $args['postid'] = $id; | ||
| 37 | $args['mb'] = $this; | ||
| 38 | $args['parentID'] = isset($_REQUEST['parentID']) ? sanitize_text_field($_REQUEST['parentID']) : $id; | ||
| 39 | $args['selectedID'] = isset($_REQUEST['pid']) ? sanitize_text_field($_REQUEST['pid']) : $id; | ||
| 40 | |||
| 41 | $args = apply_filters_ref_array('wc_rbp_metabox_render', array( &$args )); | ||
| 42 | |||
| 43 | if( $args['render_default'] ) { | ||
| 44 | $render_info .= $this->render_default_metabox($id, $post, $args); | ||
| 45 | } else { | ||
| 46 | $render_info .= $args['html']; | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | $render_info .= '</div>'; | ||
| 51 | |||
| 52 | echo $render_info; | ||
| 53 | } | ||
| 54 | |||
| 55 | public function get_post_type($id) { | ||
| 56 | $product_type = ''; | ||
| 57 | |||
| 58 | if( $terms = wp_get_object_terms($id, 'product_type') ) { | ||
| 59 | $product_type = sanitize_title(current($terms)->name); | ||
| 60 | } else { | ||
| 61 | $product_type = apply_filters('default_product_type', 'simple'); | ||
| 62 | } | ||
| 63 | return $product_type; | ||
| 64 | } | ||
| 65 | |||
| 66 | public function render_default_metabox($id, $post, $args, $type = 'default') { | ||
| 67 | $product_type = $this->get_post_type($id); | ||
| 68 | |||
| 69 | $render_info = ''; | ||
| 70 | $post_type = get_post_type($id); | ||
| 71 | |||
| 72 | if( $product_type == 'variable' || $post_type == 'product_variation' ) { | ||
| 73 | $render_info .= $this->generate_variation_selectbox($args['parentID'], $id); | ||
| 74 | } else { | ||
| 75 | ob_start(); | ||
| 76 | do_action("wc_rbp_metabox_header", $id, $product_type, $post, $this); | ||
| 77 | $render_info .= ob_get_contents(); | ||
| 78 | ob_end_clean(); | ||
| 79 | } | ||
| 80 | |||
| 81 | $prod = wc_get_product($id); | ||
| 82 | $prodType = 'simple'; | ||
| 83 | if( is_object($prod) ) { | ||
| 84 | if( wc_rbp_is_wc_v('>=', '3.0.0') ) { | ||
| 85 | $prodType = $prod->get_type(); | ||
| 86 | } else { | ||
| 87 | $prodType = $prod->product_type; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | ob_start(); | ||
| 92 | do_action('wc_rbp_before_metabox_content', $prod, $prodType); | ||
| 93 | $render_info .= ob_get_contents(); | ||
| 94 | ob_end_clean(); | ||
| 95 | |||
| 96 | $tabs = $this->get_metabox_tabs($id, $prodType); | ||
| 97 | $content = $this->get_metabox_content($id, $tabs, $prod, $prodType); | ||
| 98 | |||
| 99 | $render_info .= wc_rbp_generate_tabs($tabs, $content); | ||
| 100 | $render_info .= wc_rbp_get_editor_fields($type); | ||
| 101 | $render_info .= '<input type="hidden" id="wc_rbp_product_id" name="product_id" value="' . $id . '" /> '; | ||
| 102 | |||
| 103 | ob_start(); | ||
| 104 | do_action('wc_rbp_after_metabox_content', $prod, $prodType); | ||
| 105 | $render_info .= ob_get_contents(); | ||
| 106 | ob_end_clean(); | ||
| 107 | |||
| 108 | $render_info .= $this->render_metabox_footer($id); | ||
| 109 | |||
| 110 | return $render_info; | ||
| 111 | } | ||
| 112 | |||
| 113 | public function generate_variation_selectbox($id, $selected = '') { | ||
| 114 | |||
| 115 | $header = $this->render_selectbox_header(); | ||
| 116 | $args = array( | ||
| 117 | 'post_type' => 'product_variation', | ||
| 118 | 'post_status' => array( 'private', 'publish' ), | ||
| 119 | 'posts_per_page' => -1, | ||
| 120 | 'orderby' => array( 'menu_order' => 'ASC', 'ID' => 'DESC' ), | ||
| 121 | 'post_parent' => $id, | ||
| 122 | 'fields' => 'ids', | ||
| 123 | ); | ||
| 124 | |||
| 125 | $variations = get_children($args); | ||
| 126 | $return = ' <optgroup label="' . __("Variations", WC_RBP_TXT) . '"> '; | ||
| 127 | foreach( $variations as $ids ) { | ||
| 128 | $prod = wc_get_product($ids); | ||
| 129 | $name = '#' . $ids . ' | '; | ||
| 130 | |||
| 131 | if( wc_rbp_is_wc_v('>=', '3.0') ) { | ||
| 132 | $name .= ' ' . wc_get_formatted_variation($prod, TRUE); | ||
| 133 | } else { | ||
| 134 | $name .= ' ' . $prod->get_formatted_variation_attributes(TRUE); | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | $selecteds = ''; | ||
| 139 | if( $selected == $ids ) { | ||
| 140 | $selecteds = 'selected'; | ||
| 141 | } | ||
| 142 | $return .= '<option data-type="variation" value="' . $ids . '" ' . $selecteds . '>' . $name . '</option>'; | ||
| 143 | } | ||
| 144 | $return .= ' </optgroup> '; | ||
| 145 | |||
| 146 | $footer = $this->render_selectbox_footer(); | ||
| 147 | $return = apply_filters("role_based_price_metabox_variation_select", $return, $selected, $id); | ||
| 148 | $return = $header . $return . $footer; | ||
| 149 | return $return; | ||
| 150 | } | ||
| 151 | |||
| 152 | public function render_selectbox_header($placeholder = '') { | ||
| 153 | if( empty($placeholder) ) { | ||
| 154 | $placeholder = __("Select A Variation : ", WC_RBP_TXT); | ||
| 155 | } | ||
| 156 | $header = '<select id="wc_rbp_variation_select" style="width: 30%; display: inline-block; vertical-align: middle; margin-left: 10px;" name="wc_rbp_variation_select" class="wcrbpvariationbx"> <option value="">' . $placeholder . '</option>'; | ||
| 157 | return apply_filters("role_based_price_admin_selectbox_header", $header); | ||
| 158 | } | ||
| 159 | |||
| 160 | public function render_selectbox_footer() { | ||
| 161 | return apply_filters("role_based_price_admin_selectbox_header", '</select>'); | ||
| 162 | } | ||
| 163 | |||
| 164 | public function get_metabox_tabs($id, $prodType) { | ||
| 165 | $tabs = apply_filters('wc_rbp_before_default_product_tabs', array(), $id, $prodType); | ||
| 166 | $registered_roles = $this->registered_roles; | ||
| 167 | |||
| 168 | foreach( $this->allowed_roles as $role ) { | ||
| 169 | if( isset($registered_roles[$role]) ) { | ||
| 170 | $icon = 'dashicons dashicons-admin-users'; | ||
| 171 | $tabs[$role] = array( | ||
| 172 | 'title' => $registered_roles[$role]['name'], | ||
| 173 | 'icon' => $icon, | ||
| 174 | 'show_status' => TRUE, | ||
| 175 | ); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | $tabs = apply_filters('wc_rbp_after_default_product_tabs', $tabs, $id, $prodType); | ||
| 180 | return $tabs; | ||
| 181 | } | ||
| 182 | |||
| 183 | public function get_metabox_content($id, $tabs, $prod, $prodType) { | ||
| 184 | $content = array(); | ||
| 185 | |||
| 186 | foreach( $tabs as $tab_id => $val ) { | ||
| 187 | ob_start(); | ||
| 188 | do_action('wc_rbp_price_edit_tab_' . $tab_id . '_before', $id, $prodType, $prod, $tab_id); | ||
| 189 | do_action('wc_rbp_price_edit_tab_' . $tab_id, $id, $prodType, $prod, $tab_id); | ||
| 190 | do_action('wc_rbp_price_edit_tab_' . $tab_id . '_after', $id, $prodType, $prod, $tab_id); | ||
| 191 | |||
| 192 | $content[$tab_id] = ob_get_contents(); | ||
| 193 | ob_end_clean(); | ||
| 194 | } | ||
| 195 | |||
| 196 | return $content; | ||
| 197 | } | ||
| 198 | |||
| 199 | public function render_metabox_footer($id) { | ||
| 200 | $base_price = $this->get_base_price($id); | ||
| 201 | $clbtn = ''; | ||
| 202 | $product_type = wp_get_post_terms($id, 'product_type', array( 'fields' => 'names' )); | ||
| 203 | |||
| 204 | if( in_array('variable', $product_type) || get_post_type($id) == 'product_variation' ) { | ||
| 205 | $clbtn = '<button style="float:left;" type="button" id="wc_rbp_clear_trasient" class="button button-secondary">' . __('Clear Cache', WC_RBP_TXT) . '</button>'; | ||
| 206 | } | ||
| 207 | |||
| 208 | return ' <h2 class="" style="margin: 0px -12px -12px; border-top: 1px solid #eee; text-align:right;"> | ||
| 209 | <span class="wc_rbp_base_product_price">' . $base_price . '</span> | ||
| 210 | ' . $clbtn . ' | ||
| 211 | <button type="button" id="wc_rbp_update_price" class="button button-primary">' . __('Save Price', WC_RBP_TXT) . '</button></h2> '; | ||
| 212 | } | ||
| 213 | |||
| 214 | public function get_base_price($id) { | ||
| 215 | $pro = wc_get_product($id); | ||
| 216 | $price = ''; | ||
| 217 | if( is_object($pro) ) { | ||
| 218 | $price = array(); | ||
| 219 | $this->hook_filter(TRUE); | ||
| 220 | $price['regular_price'] = wc_rbp_price_types('regular_price') . ' : '; | ||
| 221 | $price['regular_price'] .= wc_price($pro->get_regular_price()); | ||
| 222 | |||
| 223 | $price['selling_price'] = wc_rbp_price_types('selling_price') . ' : '; | ||
| 224 | $price['selling_price'] .= wc_price($pro->get_sale_price()); | ||
| 225 | $this->hook_filter(FALSE); | ||
| 226 | $price = implode(' | ', $price); | ||
| 227 | } | ||
| 228 | $head = '<span class="headTxt">' . __("WC Product Price : ") . '</span>' . $price; | ||
| 229 | return $head; | ||
| 230 | } | ||
| 231 | |||
| 232 | public function hook_filter($hook = TRUE) { | ||
| 233 | if( $hook == TRUE ) { | ||
| 234 | add_filter('role_based_price_status', array( $this, 'base_price_return_false' )); | ||
| 235 | } | ||
| 236 | if( ! $hook == TRUE ) { | ||
| 237 | remove_filter('role_based_price_status', array( $this, 'base_price_return_false' )); | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | public function base_price_return_false($s) { | ||
| 242 | return FALSE; | ||
| 243 | } | ||
| 244 | |||
| 245 | } | ||
| 246 | |||
| 247 | return new WooCommerce_Role_Based_Price_Product_Metabox; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/includes/admin/class-price-editor-fields.php
0 → 100644
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * The admin-specific functionality of the plugin. | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/Admin | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if( ! defined('WPINC') ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price_Admin_Price_Editor_Fields { | ||
| 15 | |||
| 16 | public function __construct() { | ||
| 17 | add_action("wc_rbp_before_metabox_content", array( $this, 'register_price_fields' )); | ||
| 18 | add_filter('wc_rbp_before_default_product_tabs', array( $this, 'add_general_tab' )); | ||
| 19 | add_action('wc_rbp_price_edit_tab_general', array( $this, 'add_status_field' ), 10, 4); | ||
| 20 | |||
| 21 | } | ||
| 22 | |||
| 23 | public function add_general_tab($tabs) { | ||
| 24 | $tabs['general'] = array( 'title' => __('General', WC_RBP_TXT), | ||
| 25 | 'icon' => 'dashicons-admin-tools', | ||
| 26 | 'show_status' => FALSE, | ||
| 27 | ); | ||
| 28 | return $tabs; | ||
| 29 | } | ||
| 30 | |||
| 31 | public function add_status_field($product_id, $prodType, $prod, $tab_id) { | ||
| 32 | $status = product_rbp_status($product_id) == 'true' ? 'checked' : ''; | ||
| 33 | $content = '<div class="wc_rbp_price_container wc_rbp_popup_section wc_rbp_popup_section_' . $tab_id . '">'; | ||
| 34 | $content .= '<div class="enable_field_container">'; | ||
| 35 | $content .= '<p class="form-field ">'; | ||
| 36 | $content .= '<label class="enable_text" for="enable_role_based_price">' . __('Enable Role Based Pricing', WC_RBP_TXT) . ' </label> '; | ||
| 37 | $content .= ' <input type="checkbox" data-secondaryColor="#999" data-size="small" class="wc_rbp_checkbox" id="enable_role_based_price" name="enable_role_based_price" ' . $status . '/> '; | ||
| 38 | $content .= '</p>'; | ||
| 39 | $content .= '</div>'; | ||
| 40 | $content .= '</div>'; | ||
| 41 | echo $content; | ||
| 42 | } | ||
| 43 | |||
| 44 | public function register_price_fields() { | ||
| 45 | $allowed_roles = wc_rbp_allowed_roles(); | ||
| 46 | |||
| 47 | foreach( $allowed_roles as $role ) { | ||
| 48 | add_action('wc_rbp_price_edit_tab_' . $role, array( $this, 'generate_price_field' ), 10, 4); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | public function generate_price_field($product_id, $prodType, $prod, $tab_id) { | ||
| 53 | global $product; | ||
| 54 | $allowed_price = wc_rbp_allowed_price(); | ||
| 55 | $price_exists = wc_rbp_price_types(); | ||
| 56 | $output_html = '<div class="wc_rbp_price_container wc_rbp_popup_section wc_rbp_popup_section_' . $tab_id . '">'; | ||
| 57 | |||
| 58 | foreach( $allowed_price as $price ) { | ||
| 59 | $field_id = 'role_based_price[' . $tab_id . '][' . $price . ']'; | ||
| 60 | $defaults = array( | ||
| 61 | 'type' => 'text', | ||
| 62 | 'label' => $price_exists[$price], | ||
| 63 | 'description' => __('Enter Product\'s ') . $price_exists[$price], | ||
| 64 | 'class' => array(), | ||
| 65 | 'label_class' => array(), | ||
| 66 | 'input_class' => array( 'wc_input_price', $price, 'wc_rbp_' . $price ), | ||
| 67 | 'return' => TRUE, | ||
| 68 | 'custom_attributes' => array(), | ||
| 69 | ); | ||
| 70 | $output_html .= '<div class="wc_rbp_pop_field_50 wc_rbp_pop_field_' . $price . '">'; | ||
| 71 | $price = wc_rbp_price($product_id, $tab_id, $price); | ||
| 72 | |||
| 73 | $output_html .= woocommerce_form_field($field_id, $defaults, $price); | ||
| 74 | $output_html .= '</div>'; | ||
| 75 | } | ||
| 76 | $output_html .= '</div>'; | ||
| 77 | echo $output_html; | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | } | ||
| 82 | |||
| 83 | return new WooCommerce_Role_Based_Price_Admin_Price_Editor_Fields; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/includes/admin/class-product-functions.php
0 → 100644
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * WooCommerce Product Role Based Price Edit Functions | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/Admin | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if( ! defined('WPINC') ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price_Admin_Product_Functions { | ||
| 15 | |||
| 16 | public function __construct() { | ||
| 17 | add_action('wc_rbp_product_save_default', array( $this, 'simple_save_product_price' ), 1, 3); | ||
| 18 | } | ||
| 19 | |||
| 20 | public function simple_save_product_price(&$posted_values, &$success, &$error) { | ||
| 21 | $post_id = $posted_values['product_id']; | ||
| 22 | |||
| 23 | do_action_ref_array('wc_rbp_product_save_before', array( &$posted_values )); | ||
| 24 | if( isset($posted_values['role_based_price']) ) { | ||
| 25 | $status = isset($posted_values['enable_role_based_price']) ? TRUE : FALSE; | ||
| 26 | wc_rbp_update_role_based_price_status($post_id, $status); | ||
| 27 | wc_rbp_update_role_based_price($post_id, $posted_values['role_based_price']); | ||
| 28 | clean_post_cache($post_id); | ||
| 29 | $success['html'] = '<h3>' . __("Product Price Updated.", WC_RBP_TXT) . '</h3>'; | ||
| 30 | } else { | ||
| 31 | $error['html'] = '<h3>' . __("Price Not Defined. Please Try Again", WC_RBP_TXT) . '</h3>'; | ||
| 32 | } | ||
| 33 | do_action_ref_array('wc_rbp_product_save_after', array( &$posted_values )); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | return new WooCommerce_Role_Based_Price_Admin_Product_Functions; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * The admin-specific functionality of the plugin. | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @package Role Based Price For WooCommerce | ||
| 7 | * @subpackage Role Based Price For WooCommerce/Admin | ||
| 8 | * @since 3.0 | ||
| 9 | */ | ||
| 10 | if( ! defined('WPINC') ) { | ||
| 11 | die; | ||
| 12 | } | ||
| 13 | |||
| 14 | class WooCommerce_Role_Based_Price_Admin_Settings_Options { | ||
| 15 | |||
| 16 | public function __construct() { | ||
| 17 | add_filter('wc_rbp_settings_pages', array( $this, 'settings_pages' )); | ||
| 18 | add_filter('wc_rbp_settings_section', array( $this, 'settings_section' )); | ||
| 19 | add_filter('wc_rbp_settings_fields', array( $this, 'settings_fields' )); | ||
| 20 | } | ||
| 21 | |||
| 22 | public function settings_pages($page) { | ||
| 23 | $page[] = array( 'id' => 'general', 'slug' => 'general', 'title' => __('General', WC_RBP_TXT) ); | ||
| 24 | $page[] = array( | ||
| 25 | 'id' => 'addonssettings', | ||
| 26 | 'slug' => 'addonssettings', | ||
| 27 | 'title' => __('Extensions Options', WC_RBP_TXT), | ||
| 28 | ); | ||
| 29 | $page[] = array( 'id' => 'addons', 'slug' => 'wcrbpaddons', 'title' => __('Extensions', WC_RBP_TXT) ); | ||
| 30 | return $page; | ||
| 31 | } | ||
| 32 | |||
| 33 | public function settings_section($section) { | ||
| 34 | $section['general'][] = array( 'id' => 'general', 'title' => __('General', WC_RBP_TXT) ); | ||
| 35 | $section['addons'][] = array( 'id' => 'addons', 'title' => '' ); | ||
| 36 | $addonSettings = array( | ||
| 37 | 'addon_sample' => array( | ||
| 38 | 'id' => 'addonssettings', | ||
| 39 | 'title' => __('No Addons Activated / Installed.', WC_RBP_TXT), | ||
| 40 | ), | ||
| 41 | ); | ||
| 42 | $addonSettings = apply_filters('wc_rbp_addon_sections', $addonSettings); | ||
| 43 | |||
| 44 | if( count($addonSettings) > 1 ) | ||
| 45 | unset($addonSettings['addon_sample']); | ||
| 46 | $section['addonssettings'] = $addonSettings; | ||
| 47 | return $section; | ||
| 48 | } | ||
| 49 | |||
| 50 | public function settings_fields($fields) { | ||
| 51 | $fields['general']['general'][] = array( | ||
| 52 | 'id' => WC_RBP_DB . 'allowed_roles', | ||
| 53 | 'multiple' => 'true', | ||
| 54 | 'type' => 'select', | ||
| 55 | 'label' => __('Allowed User Roles', WC_RBP_TXT), | ||
| 56 | 'desc' => __('User Roles To List In Product Edit Page', WC_RBP_TXT), | ||
| 57 | 'options' => wc_rbp_sort_array_by_array(wc_rbp_get_user_roles_selectbox(), wc_rbp_allowed_roles()), | ||
| 58 | 'attr' => array( | ||
| 59 | 'class' => 'wc-rbp-enhanced-select', | ||
| 60 | 'multiple' => 'multiple', | ||
| 61 | ), | ||
| 62 | ); | ||
| 63 | |||
| 64 | |||
| 65 | $fields['general']['general'][] = array( | ||
| 66 | 'id' => WC_RBP_DB . 'allowed_price', | ||
| 67 | 'type' => 'select', | ||
| 68 | 'multiple' => TRUE, | ||
| 69 | 'label' => __('Allowed Product Pricing', WC_RBP_TXT), | ||
| 70 | 'desc' => __('Price Fields To List In Product Edit Page', WC_RBP_TXT), | ||
| 71 | 'options' => wc_rbp_sort_array_by_array(wc_rbp_avaiable_price_type(), wc_rbp_allowed_price()), | ||
| 72 | 'attr' => array( | ||
| 73 | 'class' => 'wc-rbp-enhanced-select', | ||
| 74 | 'style' => 'width:auto;max-width:35%;', | ||
| 75 | 'multiple' => 'multiple', | ||
| 76 | ), | ||
| 77 | ); | ||
| 78 | |||
| 79 | $price_type = wc_rbp_avaiable_price_type(); | ||
| 80 | |||
| 81 | foreach( $price_type as $pK => $pV ) { | ||
| 82 | $fields['general']['general'][] = array( | ||
| 83 | 'id' => WC_RBP_DB . $pK . '_label', | ||
| 84 | 'type' => 'text', | ||
| 85 | 'label' => $pV . __(' Label ', WC_RBP_TXT), | ||
| 86 | 'default' => $pV, | ||
| 87 | 'attr' => array( | ||
| 88 | 'style' => 'width:auto;max-width:35%;', | ||
| 89 | ), | ||
| 90 | ); | ||
| 91 | } | ||
| 92 | |||
| 93 | if( class_exists('woocommerce_wpml') ) { | ||
| 94 | $fields['general']['general'][] = array( | ||
| 95 | 'id' => WC_RBP_DB . 'enable_wpml_integration', | ||
| 96 | 'type' => 'checkbox', | ||
| 97 | 'label' => __('WPML Integration', WC_RBP_TXT), | ||
| 98 | 'desc' => __('check if you have installed wpml and the price are showing wrong. ', WC_RBP_TXT), | ||
| 99 | 'attr' => array( 'class' => 'wc_rbp_checkbox', ), | ||
| 100 | ); | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | $addonSettings = array( 'addon_sample' => array() ); | ||
| 105 | $addonSettings = apply_filters('wc_rbp_addon_fields', $addonSettings); | ||
| 106 | unset($addonSettings['addon_sample']); | ||
| 107 | $fields['addonssettings'] = $addonSettings; | ||
| 108 | |||
| 109 | return $fields; | ||
| 110 | } | ||
| 111 | |||
| 112 | } | ||
| 113 | |||
| 114 | return new WooCommerce_Role_Based_Price_Admin_Settings_Options; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Class for registering settings and sections and for display of the settings form(s). | ||
| 4 | * For detailed instructions see: https://github.com/keesiemeijer/WP-Settings | ||
| 5 | * | ||
| 6 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 7 | * @package Role Based Price For WooCommerce | ||
| 8 | * @subpackage Role Based Price For WooCommerce/WordPress/Settings | ||
| 9 | * @since 3.0 | ||
| 10 | * @version 2.0 | ||
| 11 | * @author keesiemeijer | ||
| 12 | */ | ||
| 13 | if( ! defined('WPINC') ) { | ||
| 14 | die; | ||
| 15 | } | ||
| 16 | |||
| 17 | class WooCommerce_Role_Based_Price_Settings_Framework { | ||
| 18 | public $settings; | ||
| 19 | private $page_hook = ''; | ||
| 20 | private $settings_page; | ||
| 21 | private $settings_section; | ||
| 22 | private $settings_fields; | ||
| 23 | private $create_function; | ||
| 24 | private $settings_key; | ||
| 25 | private $settings_values; | ||
| 26 | |||
| 27 | function __construct($page_hook = '') { | ||
| 28 | $this->settings_section = array(); | ||
| 29 | $this->settings_fields = array(); | ||
| 30 | $this->create_function = array(); | ||
| 31 | $this->add_settings_pages(); | ||
| 32 | //$this->get_settings(); | ||
| 33 | $this->add_settings_section(); | ||
| 34 | $this->create_callback_function(); | ||
| 35 | $this->page_hook = $page_hook; | ||
| 36 | |||
| 37 | if( empty($page_hook) ) { | ||
| 38 | add_action('admin_menu', array( $this, 'admin_menu' )); | ||
| 39 | } | ||
| 40 | add_action('admin_init', array( $this, 'admin_init' )); | ||
| 41 | } | ||
| 42 | |||
| 43 | private function add_settings_pages() { | ||
| 44 | $pages = array(); | ||
| 45 | $pages = apply_filters('wc_rbp_settings_pages', $pages); | ||
| 46 | $this->settings_page = $pages; | ||
| 47 | } | ||
| 48 | |||
| 49 | private function add_settings_section() { | ||
| 50 | $section = array(); | ||
| 51 | $section = apply_filters('wc_rbp_settings_section', $section); | ||
| 52 | $this->settings_section = $section; | ||
| 53 | } | ||
| 54 | |||
| 55 | private function create_callback_function() { | ||
| 56 | $sec = $this->settings_section; | ||
| 57 | |||
| 58 | foreach( $sec as $sk => $s ) { | ||
| 59 | if( is_array($s) ) { | ||
| 60 | $c = count($s); | ||
| 61 | $a = 0; | ||
| 62 | while( $a < $c ) { | ||
| 63 | if( isset($s[$a]['validate_callback']) ) { | ||
| 64 | $this->create_function[] = $s[$a]['id']; | ||
| 65 | $s[$a]['validate_callback'] = ''; | ||
| 66 | $file = addslashes(WC_RBP_SETTINGS . 'validate-' . $s[$a]['id'] . '.php'); | ||
| 67 | $s[$a]['validate_callback'] = create_function('$fields', 'do_action("wc_rbp_settings_validate",$fields); do_action("wc_rbp_settings_validate_' . $s[$a]['id'] . '",$fields);'); | ||
| 68 | } | ||
| 69 | $a++; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | $this->settings_section[$sk] = $s; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | function admin_menu() { | ||
| 78 | $this->page_hook = add_submenu_page('woocommerce', __('Role Based Price Settings', WC_RBP_TXT), __('Role Based Price Settings', WC_RBP_TXT), 'manage_woocommerce', WC_RBP_SLUG . '-settings', array( | ||
| 79 | $this, | ||
| 80 | 'admin_page', | ||
| 81 | )); | ||
| 82 | } | ||
| 83 | |||
| 84 | function admin_init() { | ||
| 85 | $this->settings = new WooCommerce_Role_Based_Price_WP_Settings(); | ||
| 86 | $this->add_settings_fields(); | ||
| 87 | $this->settings->add_pages($this->settings_page); | ||
| 88 | $sections = $this->settings_section; | ||
| 89 | |||
| 90 | foreach( $sections as $page_id => $section_value ) { | ||
| 91 | $pages = $this->settings->add_sections($page_id, $section_value); | ||
| 92 | } | ||
| 93 | |||
| 94 | $fields = $this->settings_field; | ||
| 95 | foreach( $fields as $page_id => $section_fields ) { | ||
| 96 | foreach( $section_fields as $section_id => $sfields ) { | ||
| 97 | if( is_array($sfields) ) { | ||
| 98 | foreach( $sfields as $f ) { | ||
| 99 | $pages = $this->settings->add_field($page_id, $section_id, $f); | ||
| 100 | } | ||
| 101 | |||
| 102 | } else { | ||
| 103 | $pages = $this->settings->add_field($page_id, $section_id, $sfields); | ||
| 104 | } | ||
| 105 | |||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | $this->settings->init($pages, WC_RBP_DB); | ||
| 110 | } | ||
| 111 | |||
| 112 | private function add_settings_fields() { | ||
| 113 | global $fields; | ||
| 114 | $fields = array(); | ||
| 115 | $fields = apply_filters('wc_rbp_settings_fields', $fields); | ||
| 116 | $this->settings_field = $fields; | ||
| 117 | } | ||
| 118 | |||
| 119 | public function admin_page() { | ||
| 120 | echo '<div class="wrap wc_rbp_settings">'; | ||
| 121 | settings_errors(); | ||
| 122 | $this->settings->render_header(); | ||
| 123 | //echo $this->settings->debug; | ||
| 124 | $this->settings->render_form(); | ||
| 125 | echo '</div>'; | ||
| 126 | } | ||
| 127 | |||
| 128 | function get_option($id = '') { | ||
| 129 | if( ! empty($this->settings_values) && ! empty($id) ) { | ||
| 130 | if( isset($this->settings_values[$id]) ) { | ||
| 131 | return $this->settings_values[$id]; | ||
| 132 | } | ||
| 133 | } | ||
| 134 | return FALSE; | ||
| 135 | |||
| 136 | } | ||
| 137 | |||
| 138 | function get_settings($key = '') { | ||
| 139 | $values = array(); | ||
| 140 | foreach( $this->settings_page as $settings ) { | ||
| 141 | $this->settings_key[] = WC_RBP_DB . $settings['slug']; | ||
| 142 | $db_val = get_option(WC_RBP_DB . $settings['slug']); | ||
| 143 | if( is_array($db_val) ) { | ||
| 144 | unset($db_val['section_id']); | ||
| 145 | $values = array_merge($db_val, $values); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | $this->settings_values = $values; | ||
| 150 | return $values; | ||
| 151 | } | ||
| 152 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | </div></div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | $slug = $wc_rbp_plugin_data['addon_slug']; | ||
| 3 | $cat_slug = implode(' wc-rbp-addon-', array_keys($wc_rbp_plugin_data['Category'])); | ||
| 4 | |||
| 5 | $wrapperClass = 'plugin-card plugin-card-' . $slug . ' wc-rbp-addon-all wc-rbp-addon-' . $cat_slug; | ||
| 6 | |||
| 7 | if( $wc_rbp_plugin_data['is_active'] ) { | ||
| 8 | $wrapperClass .= ' wc-rbp-addon-active'; | ||
| 9 | } else { | ||
| 10 | $wrapperClass .= ' wc-rbp-addon-inactive'; | ||
| 11 | } | ||
| 12 | |||
| 13 | ?> | ||
| 14 | <div class="<?php echo $wrapperClass; ?>" id="<?php echo $slug; ?>"> | ||
| 15 | <?php wc_rbp_get_ajax_overlay(); ?> | ||
| 16 | <div class="plugin-card-top"> | ||
| 17 | <div class="name column-name"> | ||
| 18 | <h3> | ||
| 19 | <?php echo $wc_rbp_plugin_data['Name']; ?> | ||
| 20 | [ | ||
| 21 | <small><?php _e('V', WC_RBP_TXT); ?><?php echo $wc_rbp_plugin_data['Version']; ?></small> | ||
| 22 | ] | ||
| 23 | <?php $this->get_addon_icon($wc_rbp_plugin_data); ?> | ||
| 24 | </h3> | ||
| 25 | </div> | ||
| 26 | <div class="desc column-description"> | ||
| 27 | <p><?php echo $wc_rbp_plugin_data['Description']; ?></p> | ||
| 28 | <p class="authors"> | ||
| 29 | |||
| 30 | <cite> | ||
| 31 | <?php _e('By', WC_RBP_TXT); ?> | ||
| 32 | <a href="<?php echo $wc_rbp_plugin_data['AuthorURI']; ?>"> <?php echo $wc_rbp_plugin_data['Author']; ?></a> | ||
| 33 | </cite> | ||
| 34 | </p> | ||
| 35 | </div> | ||
| 36 | </div> | ||
| 37 | <div class="plugin-card-top wc-rbp-addons-required-plugins"> | ||
| 38 | <?php if( ! empty($required_plugins) ): ?> | ||
| 39 | <div> | ||
| 40 | <h3><?php _e('Required Plugins :', WC_RBP_TXT); ?></h3> | ||
| 41 | <ul> | ||
| 42 | <?php | ||
| 43 | $echo = ''; | ||
| 44 | foreach( $required_plugins as $plugin ) { | ||
| 45 | $plugin_status = $this->check_plugin_status($plugin['Slug']); | ||
| 46 | $status_val = __('InActive', WC_RBP_TXT); | ||
| 47 | $class = 'deactivated'; | ||
| 48 | if( $plugin_status === 'notexist' ) { | ||
| 49 | $status_val = __('Plugin Does Not Exist', WC_RBP_TXT); | ||
| 50 | $class = 'notexist'; | ||
| 51 | } else if( $plugin_status === TRUE ) { | ||
| 52 | $status_val = __('Active', WC_RBP_TXT); | ||
| 53 | $class = 'active'; | ||
| 54 | } | ||
| 55 | if( ! isset($plugin['Version']) ) { | ||
| 56 | $plugin['version'] = ''; | ||
| 57 | } | ||
| 58 | echo '<li class="' . $class . '">'; | ||
| 59 | |||
| 60 | echo '<span class="wc_rbp_required_addon_plugin_name"> <a href="' . $plugin['URL'] . '" > ' . $plugin['Name'] . ' [' . $plugin['Version'] . '] </a> </span> : '; | ||
| 61 | echo '<span class="wc_rbp_required_addon_plugin_status ' . $class . '">' . $status_val . '</span>'; | ||
| 62 | echo '</li>'; | ||
| 63 | unset($plugin_status); | ||
| 64 | } | ||
| 65 | ?> | ||
| 66 | </ul> | ||
| 67 | <?php /*<p> <span><?php _e('Above Mentioned Plugin name with version are Tested Up to',WC_RBP_TXT);?></span> </p> */ ?> | ||
| 68 | |||
| 69 | </div> | ||
| 70 | <?php endif; ?> | ||
| 71 | |||
| 72 | <?php if( ! empty($wc_rbp_plugin_data['screenshots']) ) : ?> | ||
| 73 | <div class="addon-screenshots"> | ||
| 74 | <h3><?php _e("Screenshots", WC_RBP_TXT); ?></h3> | ||
| 75 | <ul> | ||
| 76 | <?php | ||
| 77 | $i = 1; | ||
| 78 | $url = $wc_rbp_plugin_data['addon_url']; | ||
| 79 | foreach( $wc_rbp_plugin_data['screenshots'] as $screen ) { | ||
| 80 | echo '<li><a class="thickbox" href="' . $url . basename($screen) . '?TB_iframe=true">' . $i . '</a></li>'; | ||
| 81 | $i++; | ||
| 82 | } | ||
| 83 | ?> | ||
| 84 | </ul> | ||
| 85 | </div> | ||
| 86 | |||
| 87 | <?php endif; ?> | ||
| 88 | |||
| 89 | <small><strong><?php _e('Addon Slug : ', WC_RBP_TXT); ?></strong><?php echo $wc_rbp_plugin_slug; ?></small> | ||
| 90 | </div> | ||
| 91 | <div class="plugin-card-bottom"> | ||
| 92 | <div class="column-updated" data-pluginslug="<?php echo $slug; ?>"> | ||
| 93 | <?php echo $this->get_addon_action_button($wc_rbp_plugin_slug, $required_plugins); ?> | ||
| 94 | </div> | ||
| 95 | <div class="column-downloaded"><strong><?php _e('Last Updated:', WC_RBP_TXT); ?></strong> | ||
| 96 | <span title="<?php echo $wc_rbp_plugin_data['last_update']; ?>"><?php echo $wc_rbp_plugin_data['last_update']; ?></span> | ||
| 97 | </div> | ||
| 98 | <div class="column-downloaded wc_rbp_ajax_response"></div> | ||
| 99 | </div> | ||
| 100 | </div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/includes/admin/views/ajax-modal-content.php
0 → 100644
File mode changed
wp-content/plugins/woocommerce-role-based-price/includes/admin/views/ajax-modal-footer.php
0 → 100644
| 1 | <div class="wc_rbp_price_editor_footer"> | ||
| 2 | <p> | ||
| 3 | <button name="close" onclick="Custombox.close();" id="close_modal" | ||
| 4 | class="button button-secondary"> <?php _e('Close', WC_RBP_TXT); ?> </button> | ||
| 5 | <button name="update_price" id="update_price" | ||
| 6 | class="button button-primary"> <?php _e('Update Price', WC_RBP_TXT); ?> </button> | ||
| 7 | </p> | ||
| 8 | </div> | ||
| 9 | </div> | ||
| 10 | </div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/includes/admin/views/ajax-modal-header.php
0 → 100644
| 1 | <div class="wc-rbp-modal wc-rbp-modal-ajax" style="display: block;"> | ||
| 2 | <button type="button" class="close" onclick="Custombox.close();"><span>×</span></button> | ||
| 3 | <h4 class="title"><?php _e('Role Based Price Editor'); ?> </h4> | ||
| 4 | <div class="wc-rbp-modal-content text"> | ||
| 5 | |||
| 6 | |||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/includes/admin/views/ajax-modal-price-editor.php
0 → 100644
| 1 | <?php global $type, $product_id; ?> | ||
| 2 | |||
| 3 | <div class="wc_rbp_price_editor_fields" style="display:none;"> | ||
| 4 | <form method="post" action="<?php echo admin_url('admin-ajax.php'); ?>" id="wc_rbp_price_editor_form"> | ||
| 5 | <div class="wc_rbp_hidden_fields"> | ||
| 6 | <?php echo wc_rbp_get_editor_fields($type); ?> | ||
| 7 | </div> | ||
| 8 | <div class="hide hidden wc_rbp_price_editor_ajax_response"></div> | ||
| 9 | <?php | ||
| 10 | |||
| 11 | $tabs = array(); | ||
| 12 | $allowed_roles = wc_rbp_allowed_roles(); | ||
| 13 | $registered_roles = wc_rbp_get_wp_roles(); | ||
| 14 | |||
| 15 | foreach( $allowed_roles as $role ) { | ||
| 16 | if( isset($registered_roles[$role]) ) { | ||
| 17 | $tabs[$role] = $registered_roles[$role]['name']; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | $tabs = apply_filters('wc_rbp_price_editor_tabs', $tabs, $product_id, $type); | ||
| 22 | $tab_pos = wc_rbp_option('price_editor_tab_pos'); | ||
| 23 | extract(wc_rbp_get_tab_pos($tab_pos)); | ||
| 24 | |||
| 25 | if( $type == 'simple' ) { | ||
| 26 | echo '<input type="hidden" name="product_id" value="' . $product_id . '" /> '; | ||
| 27 | } | ||
| 28 | |||
| 29 | do_action('wc_rbp_price_edit_top', $product_id, $type); | ||
| 30 | echo '<div class="tab_container">'; | ||
| 31 | echo '<div class="wc_rbp_tabs" data-tabsPosition="' . $tab_pos . '" | ||
| 32 | data-horizontalPosition="' . $horizontalPosition . '" | ||
| 33 | data-verticalPosition="' . $verticalPosition . '">'; | ||
| 34 | |||
| 35 | foreach( $tabs as $tabID => $name ) { | ||
| 36 | echo '<div data-pws-tab-name="' . $name . '" data-pws-tab="' . $tabID . '" class="pws_hide pws_tab_single" data-pws-tab-id="' . $tabID . '">'; | ||
| 37 | do_action('wc_rbp_price_edit_tab_before', $product_id, $type, $tabID); | ||
| 38 | do_action('wc_rbp_price_edit_tab_' . $tabID . '_before', $product_id, $type, $tabID); | ||
| 39 | do_action('wc_rbp_price_edit_tab_' . $tabID, $product_id, $type, $tabID); | ||
| 40 | do_action('wc_rbp_price_edit_tab_' . $tabID . '_after', $product_id, $type, $tabID); | ||
| 41 | do_action('wc_rbp_price_edit_tab_after', $product_id, $type, $tabID); | ||
| 42 | echo '</div>'; | ||
| 43 | } | ||
| 44 | |||
| 45 | echo '</div>'; | ||
| 46 | echo '</div>'; | ||
| 47 | do_action('wc_rbp_price_edit_bottom', $product_id, $type); | ||
| 48 | ?> | ||
| 49 | </form> | ||
| 50 | </div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/includes/admin/views/plugin-welcome-page.php
0 → 100644
| 1 | <div class="wrap about-wrap"> | ||
| 2 | <h1><?php _e("Welcome To", WC_RBP_TXT); | ||
| 3 | echo ' ' . __("Role Based Price For WooCommerce", WC_RBP_TXT) . ' ' . WC_RBP_V; ?></h1> | ||
| 4 | <p class="about-text"> | ||
| 5 | <?php echo WC_RBP_NAME; | ||
| 6 | _e(" now with improved speed and stability"); ?> | ||
| 7 | </p> | ||
| 8 | <div class="wp-badge"><?php echo WC_RBP_V; ?></div> | ||
| 9 | </div> | ||
| 10 | |||
| 11 | |||
| 12 | <style> | ||
| 13 | .wp-badge { | ||
| 14 | background-image : url("https://plugins.svn.wordpress.org/woocommerce-role-based-price/assets/icon-256x256.jpg") !important; | ||
| 15 | background-position : center top !important; | ||
| 16 | background-size : 100% auto !important; | ||
| 17 | padding-top : 140px !important; | ||
| 18 | padding-bottom : 3px !important; | ||
| 19 | height : auto !important; | ||
| 20 | } | ||
| 21 | </style> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Dependency Checker | ||
| 4 | * | ||
| 5 | * Checks if required Dependency plugin is enabled | ||
| 6 | * | ||
| 7 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 8 | * @package Role Based Price For WooCommerce | ||
| 9 | * @subpackage Role Based Price For WooCommerce/FrontEnd | ||
| 10 | * @since 3.0 | ||
| 11 | */ | ||
| 12 | if( ! defined('WPINC') ) { | ||
| 13 | die; | ||
| 14 | } | ||
| 15 | |||
| 16 | class WooCommerce_Role_Based_Price_Functions { | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Define the core functionality of the plugin. | ||
| 20 | * | ||
| 21 | * Set the plugin name and the plugin version that can be used throughout the plugin. | ||
| 22 | * Load the dependencies, define the locale, and set the hooks for the admin area and | ||
| 23 | * the public-facing side of the site. | ||
| 24 | * | ||
| 25 | * @since 1.0.0 | ||
| 26 | */ | ||
| 27 | public function __construct() { | ||
| 28 | add_filter('woocommerce_product_object', array( $this, 'setup_product_prices' )); | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | public function setup_product_prices($product) { | ||
| 33 | if( $product == NULL ) { | ||
| 34 | return $product; | ||
| 35 | } | ||
| 36 | $product->wc_rbp = wc_rbp_get_product_price($product->ID); | ||
| 37 | $product->wc_rbp_status = wc_rbp_product_status($product->ID); | ||
| 38 | |||
| 39 | do_action_ref_array('wc_rbp_product_class_attribute', array( &$product )); | ||
| 40 | return $product; | ||
| 41 | } | ||
| 42 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Simple Product Role Based Price Settings | ||
| 4 | * | ||
| 5 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 6 | * @since 1.0 | ||
| 7 | * @package WooCommerce_Role_Based_Price | ||
| 8 | * @subpackage WooCommerce_Role_Based_Price/admin | ||
| 9 | * @author Varun Sridharan <varunsridharan23@gmail.com> | ||
| 10 | */ | ||
| 11 | if( ! defined('WPINC') ) { | ||
| 12 | exit; | ||
| 13 | } | ||
| 14 | |||
| 15 | class WooCommerce_Role_Based_Price_Shortcode_Handler { | ||
| 16 | |||
| 17 | private static $_instance = NULL; | ||
| 18 | private static $db_prices = NULL; | ||
| 19 | |||
| 20 | public function __construct() { | ||
| 21 | add_shortcode('wc_rbp', array( $this, 'shortcodehandler' )); | ||
| 22 | } | ||
| 23 | |||
| 24 | function is_aeliacs_active() { | ||
| 25 | return isset($GLOBALS['woocommerce-aelia-currencyswitcher']) && is_object($GLOBALS['woocommerce-aelia-currencyswitcher']); | ||
| 26 | } | ||
| 27 | |||
| 28 | public function shortcodehandler($attrs) { | ||
| 29 | $vars = shortcode_atts(array( | ||
| 30 | 'id' => NULL, | ||
| 31 | 'price' => 'regular_price', | ||
| 32 | 'role' => 'current', | ||
| 33 | ), $attrs, 'wc_rbp'); | ||
| 34 | |||
| 35 | if( $vars['id'] == NULL ) { | ||
| 36 | global $product; | ||
| 37 | |||
| 38 | |||
| 39 | $id = ''; | ||
| 40 | if( wc_rbp_is_wc_v('>=', '3.0.1') ) { | ||
| 41 | $id = $product->get_id(); | ||
| 42 | } else { | ||
| 43 | $product->id; | ||
| 44 | } | ||
| 45 | |||
| 46 | if( ! isset($id) ) { | ||
| 47 | return __('Invalid Product ID Given', WC_RBP_TXT); | ||
| 48 | } | ||
| 49 | $vars['id'] = $id; | ||
| 50 | } | ||
| 51 | |||
| 52 | if( $vars['role'] == NULL ) { | ||
| 53 | return __('Invalid User Role Given', WC_RBP_TXT); | ||
| 54 | } | ||
| 55 | |||
| 56 | if( $vars['price'] == 'product_regular_price' || $vars['price'] == 'product_selling_price' ) { | ||
| 57 | return self::get_base_product_price($vars['id'], $vars['price']); | ||
| 58 | } | ||
| 59 | |||
| 60 | if( $vars['price'] != 'regular_price' && $vars['price'] != 'selling_price' ) { | ||
| 61 | return __('Invalid Price Type Given', WC_RBP_TXT); | ||
| 62 | } | ||
| 63 | |||
| 64 | $product_status = product_rbp_status($vars['id']); | ||
| 65 | $this->rbpPP = ''; | ||
| 66 | if( $product_status ) { | ||
| 67 | $this->rbpPP = new WooCommerce_Role_Based_Price_Product_Pricing; | ||
| 68 | |||
| 69 | if( $vars['role'] == 'current' ) { | ||
| 70 | $vars['role'] = wc_rbp_get_current_user(); | ||
| 71 | } | ||
| 72 | |||
| 73 | return self::get_selprice($vars['role'], $vars['price'], $vars['id']); | ||
| 74 | } | ||
| 75 | return ''; | ||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | public function get_base_product_price($id, $price) { | ||
| 80 | if( ! defined('WC_RBP_SHORTCODE_PRODUCT_BASE_PRICING') ) { | ||
| 81 | define('WC_RBP_SHORTCODE_PRODUCT_BASE_PRICING', TRUE); | ||
| 82 | } | ||
| 83 | |||
| 84 | $product = new WC_Product($id); | ||
| 85 | if( $price == 'product_regular_price' ) { | ||
| 86 | return $product->get_regular_price(); | ||
| 87 | } | ||
| 88 | if( $price == 'product_selling_price' ) { | ||
| 89 | return $product->get_sale_price(); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | public function get_selprice($role, $price = 'all', $product_id) { | ||
| 94 | $product = wc_get_product($product_id); | ||
| 95 | $p = $this->rbpPP->get_product_price('', $product, $price, $role); | ||
| 96 | return wc_price($p); | ||
| 97 | } | ||
| 98 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
File mode changed
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | |||
| 3 | /** | ||
| 4 | * Fired during plugin activation. | ||
| 5 | * | ||
| 6 | * This class defines all code necessary to run during the plugin's activation. | ||
| 7 | * | ||
| 8 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 9 | * @package Role Based Price For WooCommerce | ||
| 10 | * @subpackage Role Based Price For WooCommerce/core | ||
| 11 | * @since 3.0 | ||
| 12 | */ | ||
| 13 | class WooCommerce_Role_Based_Price_Activator { | ||
| 14 | |||
| 15 | public function __construct() { | ||
| 16 | } | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Short Description. (use period) | ||
| 20 | * | ||
| 21 | * Long Description. | ||
| 22 | * | ||
| 23 | * @since 1.0.0 | ||
| 24 | */ | ||
| 25 | public static function activate() { | ||
| 26 | require_once( WC_RBP_INC . 'helpers/class-version-check.php' ); | ||
| 27 | require_once( WC_RBP_INC . 'helpers/class-dependencies.php' ); | ||
| 28 | |||
| 29 | if( WooCommerce_Role_Based_Price_Dependencies(WC_RBP_DEPEN) ) { | ||
| 30 | WooCommerce_Role_Based_Price_Version_Check::activation_check('3.7'); | ||
| 31 | |||
| 32 | $message = '<h3> <center> ' . __("Thank you for installing <strong>Role Based Price For WooCommerce</strong> : <strong>Version 3.0 </strong>", WC_RBP_TXT) . '</center> </h3>'; | ||
| 33 | $message .= '<p>' . __("We have worked entire 1 year to improve our plugin to best of our ability and we hope you will enjoy working with it. We are always open for your sugestions and feature requests", WC_RBP_TXT) . '</p>'; | ||
| 34 | |||
| 35 | $message .= '</hr>'; | ||
| 36 | $message .= '<p>' . __("If you have installed <strong>WPRB</strong> for the 1st time or upgrading from <strong> Version 2.8.7</strong> then you will need to update its' settings once again or this plugin will not function properly. ", WC_RBP_TXT); | ||
| 37 | |||
| 38 | $url = admin_url('admin.php?page=woocommerce-role-based-price-settings'); | ||
| 39 | $message .= '<a href="' . $url . '" class="button button-primary">' . __("Click Here to update the settings", WC_RBP_TXT) . '</a> </p>'; | ||
| 40 | |||
| 41 | wc_rbp_admin_update($message, 1, 'activate_message', array(), array( 'wraper' => FALSE, 'times' => 1 )); | ||
| 42 | |||
| 43 | set_transient('_welcome_redirect_wcrbp', TRUE, 60); | ||
| 44 | |||
| 45 | } else { | ||
| 46 | if( is_plugin_active(WC_RBP_FILE) ) { | ||
| 47 | deactivate_plugins(WC_RBP_FILE); | ||
| 48 | } | ||
| 49 | wp_die(wc_rbp_dependency_message()); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | |||
| 3 | /** | ||
| 4 | * Fired during plugin deactivation. | ||
| 5 | * | ||
| 6 | * This class defines all code necessary to run during the plugin's deactivation. | ||
| 7 | * | ||
| 8 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 9 | * @package Role Based Price For WooCommerce | ||
| 10 | * @subpackage Role Based Price For WooCommerce/core | ||
| 11 | * @since 3.0 | ||
| 12 | */ | ||
| 13 | class WooCommerce_Role_Based_Price_Deactivator { | ||
| 14 | /** | ||
| 15 | * Short Description. (use period) | ||
| 16 | * | ||
| 17 | * Long Description. | ||
| 18 | * | ||
| 19 | * @since 1.0.0 | ||
| 20 | */ | ||
| 21 | public static function deactivate() { | ||
| 22 | |||
| 23 | } | ||
| 24 | |||
| 25 | public static function dependency_deactivate() { | ||
| 26 | if( is_plugin_active(WC_RBP_FILE) ) { | ||
| 27 | add_action('update_option_active_plugins', array( __CLASS__, 'deactivate_dependent' )); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | public static function deactivate_dependent() { | ||
| 32 | delete_transient('_welcome_redirect_wcrbp'); | ||
| 33 | deactivate_plugins(WC_RBP_FILE); | ||
| 34 | } | ||
| 35 | |||
| 36 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Dependency Checker | ||
| 4 | * | ||
| 5 | * Checks if required Dependency plugin is enabled | ||
| 6 | * | ||
| 7 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 8 | * @package Role Based Price For WooCommerce | ||
| 9 | * @subpackage Role Based Price For WooCommerce/core | ||
| 10 | * @since 3.0 | ||
| 11 | */ | ||
| 12 | |||
| 13 | if( ! class_exists('WooCommerce_Role_Based_Price_Dependencies') ) { | ||
| 14 | class WooCommerce_Role_Based_Price_Dependencies { | ||
| 15 | |||
| 16 | private static $active_plugins; | ||
| 17 | |||
| 18 | public static function init() { | ||
| 19 | self::$active_plugins = (array) get_option('active_plugins', array()); | ||
| 20 | if( is_multisite() ) | ||
| 21 | self::$active_plugins = array_merge(self::$active_plugins, get_site_option('active_sitewide_plugins', array())); | ||
| 22 | } | ||
| 23 | |||
| 24 | public static function active_check($pluginToCheck = '') { | ||
| 25 | if( ! self::$active_plugins ) | ||
| 26 | self::init(); | ||
| 27 | return in_array($pluginToCheck, self::$active_plugins) || array_key_exists($pluginToCheck, self::$active_plugins); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
| 31 | /** | ||
| 32 | * WC Detection | ||
| 33 | */ | ||
| 34 | if( ! function_exists('WooCommerce_Role_Based_Price_Dependencies') ) { | ||
| 35 | function WooCommerce_Role_Based_Price_Dependencies($pluginToCheck = 'woocommerce/woocommerce.php') { | ||
| 36 | return WooCommerce_Role_Based_Price_Dependencies::active_check($pluginToCheck); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | ?> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /** | ||
| 4 | * Check the version of WordPress | ||
| 5 | * | ||
| 6 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 7 | * @package Role Based Price For WooCommerce | ||
| 8 | * @subpackage Role Based Price For WooCommerce/core | ||
| 9 | * @since 3.0 | ||
| 10 | */ | ||
| 11 | class WooCommerce_Role_Based_Price_Version_Check { | ||
| 12 | static $version; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * The primary sanity check, automatically disable the plugin on activation if it doesn't meet minimum requirements | ||
| 16 | * | ||
| 17 | * @since 1.0.0 | ||
| 18 | */ | ||
| 19 | public static function activation_check($version) { | ||
| 20 | self::$version = $version; | ||
| 21 | if( ! self::compatible_version() ) { | ||
| 22 | deactivate_plugins(WC_RBP_FILE); | ||
| 23 | wp_die(__(WC_RBP_NAME . ' requires WordPress ' . self::$version . ' or higher!', WC_RBP_TXT)); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Check current version against $prefix_version_check | ||
| 29 | * | ||
| 30 | * @since 1.0.0 | ||
| 31 | */ | ||
| 32 | public static function compatible_version() { | ||
| 33 | if( version_compare($GLOBALS['wp_version'], self::$version, '<') ) { | ||
| 34 | return FALSE; | ||
| 35 | } | ||
| 36 | return TRUE; | ||
| 37 | } | ||
| 38 | |||
| 39 | /** | ||
| 40 | * The backup sanity check, in case the plugin is activated in a weird way, or the versions change after activation | ||
| 41 | * | ||
| 42 | * @since 1.0.0 | ||
| 43 | */ | ||
| 44 | public function check_version() { | ||
| 45 | if( ! self::compatible_version() ) { | ||
| 46 | if( is_plugin_active(WC_RBP_FILE) ) { | ||
| 47 | deactivate_plugins(WC_RBP_FILE); | ||
| 48 | add_action('admin_notices', array( $this, 'disabled_notice' )); | ||
| 49 | if( isset($_GET['activate']) ) { | ||
| 50 | unset($_GET['activate']); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | /** | ||
| 57 | * Text to display in the notice | ||
| 58 | * | ||
| 59 | * @since 1.0.0 | ||
| 60 | */ | ||
| 61 | public function disabled_notice() { | ||
| 62 | echo '<strong>' . esc_html__(WC_RBP_NAME . ' requires WordPress ' . self::$version . ' or higher!', WC_RBP_TXT) . '</strong>'; | ||
| 63 | } | ||
| 64 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
34.3 KB
| 1 | ; | ||
| 2 | ( function( $, window, document ) { | ||
| 3 | 'use strict'; | ||
| 4 | |||
| 5 | $.WCRBP = $.WCRBP || {}; | ||
| 6 | |||
| 7 | |||
| 8 | /** | ||
| 9 | * Global Functions | ||
| 10 | */ | ||
| 11 | /* $.WCRBP.validate_selling_price = function (e) { | ||
| 12 | var sale_price_field = $(this), | ||
| 13 | regular_price_field; | ||
| 14 | |||
| 15 | regular_price_field = sale_price_field.parents('.wc_rbp_price_container').find('.wc_rbp_regular_price'); | ||
| 16 | |||
| 17 | var sale_price = parseFloat(window.accounting.unformat(sale_price_field.val(), woocommerce_admin.mon_decimal_point)); | ||
| 18 | var regular_price = parseFloat(window.accounting.unformat(regular_price_field.val(), woocommerce_admin.mon_decimal_point)); | ||
| 19 | |||
| 20 | |||
| 21 | if ( sale_price >= regular_price ) { | ||
| 22 | $(document.body).triggerHandler('wc_add_error_tip', [$(this), 'i18_sale_less_than_regular_error']); | ||
| 23 | if ( 'change' === e.type ) { | ||
| 24 | if ( sale_price >= regular_price ) { | ||
| 25 | $(this).val(''); | ||
| 26 | $('div#wc-rbp-product-editor #wc_rbp_update_price').removeAttr('disabled'); | ||
| 27 | } | ||
| 28 | } else { | ||
| 29 | $('div#wc-rbp-product-editor #wc_rbp_update_price').attr('disabled', 'disabled'); | ||
| 30 | } | ||
| 31 | } else { | ||
| 32 | $(document.body).triggerHandler('wc_remove_error_tip', [$(this), 'i18_sale_less_than_regular_error']); | ||
| 33 | $('div#wc-rbp-product-editor #wc_rbp_update_price').removeAttr('disabled'); | ||
| 34 | } | ||
| 35 | };*/ | ||
| 36 | |||
| 37 | $.WCRBP.tab_navigation = function( e ) { | ||
| 38 | e.preventDefault(); | ||
| 39 | |||
| 40 | var $li = jQuery( this ).parent(), | ||
| 41 | panel = $li.data( 'panel' ), | ||
| 42 | $wrapper = $li.closest( '.wcrbp-tabs' ), | ||
| 43 | $panel = $wrapper.find( '.wcrbp-tab-panel-' + panel ); | ||
| 44 | |||
| 45 | $li.addClass( 'wcrbp-tab-active' ).siblings().removeClass( 'wcrbp-tab-active' ); | ||
| 46 | $panel.show().siblings().hide(); | ||
| 47 | }; | ||
| 48 | |||
| 49 | $.WCRBP.render_wootabs = function() { | ||
| 50 | $( ".wcrbp-tab-nav" ).on( "click", 'a', $.WCRBP.tab_navigation ); | ||
| 51 | |||
| 52 | if( !$( '.wcrbp-tab-active' ).is( 'visible' ) ) { | ||
| 53 | var activePane = $( '.wcrbp-tab-panel[style*="block"]' ).index(); | ||
| 54 | |||
| 55 | if( activePane >= 0 ) { | ||
| 56 | $( '.wcrbp-tab-nav li' ).removeClass( 'wcrbp-tab-active' ); | ||
| 57 | $( '.wcrbp-tab-nav li' ).eq( activePane ).addClass( 'wcrbp-tab-active' ); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | $( '.wcrbp-tab-active a' ).trigger( 'click' ); | ||
| 62 | $( '.wcrbp-tabs-no-wrapper' ).closest( '.postbox' ).addClass( 'wcrbp-tabs-no-controls' ); | ||
| 63 | |||
| 64 | |||
| 65 | }; | ||
| 66 | |||
| 67 | $.WCRBP.block = function( $elem ) { | ||
| 68 | $elem.block( { | ||
| 69 | message: null, | ||
| 70 | overlayCSS: { | ||
| 71 | background: '#fff', | ||
| 72 | opacity: 0.6 | ||
| 73 | } | ||
| 74 | } ); | ||
| 75 | }; | ||
| 76 | |||
| 77 | $.WCRBP.unblock = function( $elem ) { | ||
| 78 | $elem.unblock(); | ||
| 79 | }; | ||
| 80 | |||
| 81 | $.WCRBP.render_price_status = function() { | ||
| 82 | $( '.wcrbp-tab-nav > li' ).each( function() { | ||
| 83 | if( $( this ).attr( 'data-status' ) == 'yes' ) { | ||
| 84 | var $this = $( this ), | ||
| 85 | divClass = 'div.wcrbp-tab-panel-' + $this.attr( 'data-panel' ), | ||
| 86 | filled = 0, | ||
| 87 | unfilled = 0, | ||
| 88 | totalf = 0; | ||
| 89 | |||
| 90 | $( divClass ).find( 'input[type=text]' ).each( function() { | ||
| 91 | if( $( this ).hasClass( "include_count" ) || !$( this ).hasClass( "exclude_count" ) ) { | ||
| 92 | if( $( this ).val() == '' ) { | ||
| 93 | unfilled = unfilled + 1; | ||
| 94 | } else { | ||
| 95 | filled = filled + 1; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } ); | ||
| 99 | |||
| 100 | totalf = filled + unfilled; | ||
| 101 | |||
| 102 | $this.find( '.wc-rbp-tab-status' ).removeClass( 'bgred' ); | ||
| 103 | $this.find( '.wc-rbp-tab-status' ).removeClass( 'bggreen' ); | ||
| 104 | $this.find( '.wc-rbp-tab-status' ).removeClass( 'bgblue' ); | ||
| 105 | |||
| 106 | if( filled == 0 && unfilled > 0 ) { | ||
| 107 | $this.find( '.wc-rbp-tab-status' ).addClass( 'bgred' ); | ||
| 108 | } else if( filled > 0 && unfilled > 0 ) { | ||
| 109 | $this.find( '.wc-rbp-tab-status' ).addClass( 'bgblue' ); | ||
| 110 | } else if( filled > 0 && unfilled == 0 ) { | ||
| 111 | $this.find( '.wc-rbp-tab-status' ).addClass( 'bggreen' ); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | } ); | ||
| 116 | }; | ||
| 117 | |||
| 118 | $.WCRBP.add_variation_selectbox = function() { | ||
| 119 | if( $( ".wcrbpvariationbx" ).size() > 0 ) { | ||
| 120 | $( ".wcrbpvariationbx" ).appendTo( "#wc-rbp-product-editor .hndle span" ); | ||
| 121 | } | ||
| 122 | |||
| 123 | if( jQuery( '.wcrbpvariationbx' ).size() > 0 ) { | ||
| 124 | jQuery( '.wcrbpvariationbx' ).selectize( { | ||
| 125 | plugins: [ 'remove_button', 'restore_on_backspace' ], | ||
| 126 | persist: false, | ||
| 127 | create: false, | ||
| 128 | onChange: function( value ) { | ||
| 129 | $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 130 | var $select = this; | ||
| 131 | var $parentID = $( 'input#post_ID' ).val(); | ||
| 132 | $.ajax( { | ||
| 133 | url: ajaxurl + '?action=wc_rbp_metabox_refersh&pid=' + value + '&parentID=' + $parentID, | ||
| 134 | method: "GET", | ||
| 135 | data: '', | ||
| 136 | } ).done( function( response ) { | ||
| 137 | if( response.success === true ) { | ||
| 138 | $select.destroy(); | ||
| 139 | $( '.wcrbpvariationbx' ).remove(); | ||
| 140 | $( '#wc-rbp-product-editor .inside' ).html( response.data ); | ||
| 141 | $.WCRBP.render_wootabs(); | ||
| 142 | $.WCRBP.add_variation_selectbox(); | ||
| 143 | $( "#wc-rbp-product-editor .inside input.wc_rbp_checkbox" ).wcrbp_checkbox(); | ||
| 144 | $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 145 | $.WCRBP.render_price_status(); | ||
| 146 | } | ||
| 147 | } ) | ||
| 148 | } | ||
| 149 | } ); | ||
| 150 | } | ||
| 151 | }; | ||
| 152 | |||
| 153 | $.WCRBP.move_selectbox_metabox = function() { | ||
| 154 | $( '#wc-rbp-product-editor' ).find( '.hndle' ).unbind( 'click' ); | ||
| 155 | |||
| 156 | $( '#wc-rbp-product-editor' ).on( 'click', '.hndle', function( event ) { | ||
| 157 | event.preventDefault(); | ||
| 158 | if( $( event.target ).filter( 'input, option, label, select, div, span' ).size() ) { | ||
| 159 | jQuery( '#wc-rbp-product-editor' ).toggleClass( 'closed' ); | ||
| 160 | } | ||
| 161 | |||
| 162 | return; | ||
| 163 | } ); | ||
| 164 | }; | ||
| 165 | |||
| 166 | $.WCRBP.action_save_product_prices = function() { | ||
| 167 | var $clickedBtn = $( this ), | ||
| 168 | $data = $( 'div#wc-rbp-product-editor :input' ).serialize(), | ||
| 169 | $form = $( '.wc-rbp-metabox-container' ), | ||
| 170 | $action = $form.attr( 'action' ), | ||
| 171 | $method = $form.attr( 'method' ); | ||
| 172 | |||
| 173 | $clickedBtn.attr( 'disabled', 'disable' ); | ||
| 174 | |||
| 175 | $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 176 | |||
| 177 | $.ajax( { | ||
| 178 | url: $action, | ||
| 179 | method: $method, | ||
| 180 | data: $data, | ||
| 181 | } ).done( function( data ) { | ||
| 182 | $clickedBtn.removeAttr( 'disabled' ); | ||
| 183 | $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 184 | $( 'div.wc_rbp_hidden_fields' ).html( data.data.hidden_fields ); | ||
| 185 | $( 'div.wc_rbp_price_editor_ajax_response' ).html( data.data.html ).fadeIn( 'slow' ); | ||
| 186 | setTimeout( 2000, function() { | ||
| 187 | jQuery( 'div.wc_rbp_price_editor_ajax_response' ).fadeOut( 'slow' ); | ||
| 188 | } ); | ||
| 189 | } ) | ||
| 190 | }; | ||
| 191 | |||
| 192 | $.WCRBP.action_clear_product_prices = function() { | ||
| 193 | var $clickedBtn = $( this ); | ||
| 194 | $clickedBtn.attr( 'disabled', 'disable' ); | ||
| 195 | |||
| 196 | $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 197 | |||
| 198 | $.ajax( { | ||
| 199 | url: ajaxurl, | ||
| 200 | method: 'post', | ||
| 201 | data: { post_id: $( "#post_ID" ).val(), action: "wc_rbp_clear_variation_cache" } | ||
| 202 | } ).done( function( data ) { | ||
| 203 | $clickedBtn.removeAttr( 'disabled' ); | ||
| 204 | $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 205 | $( 'div.wc_rbp_price_editor_ajax_response' ).html( data.data.html ).fadeIn( 'slow' ); | ||
| 206 | setTimeout( 2000, function() { | ||
| 207 | jQuery( 'div.wc_rbp_price_editor_ajax_response' ).fadeOut( 'slow' ); | ||
| 208 | } ); | ||
| 209 | } ) | ||
| 210 | }; | ||
| 211 | |||
| 212 | $.WCRBP.basic_init_metabox = function() { | ||
| 213 | //$(document.body).on('keyup change', '.wc_rbp_selling_price', $.WCRBP.validate_selling_price); | ||
| 214 | |||
| 215 | if( $( "input.wc_rbp_checkbox" ).size() > 0 ) { | ||
| 216 | $( "input.wc_rbp_checkbox" ).wcrbp_checkbox(); | ||
| 217 | } | ||
| 218 | |||
| 219 | if( $( ".wcrbpvariationbx" ).size() > 0 ) { | ||
| 220 | $.WCRBP.add_variation_selectbox(); | ||
| 221 | } | ||
| 222 | |||
| 223 | if( $( ".wcrbp-tabs" ).size() > 0 ) { | ||
| 224 | $.WCRBP.block( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 225 | $.WCRBP.render_wootabs(); | ||
| 226 | $.WCRBP.move_selectbox_metabox(); | ||
| 227 | $.WCRBP.render_price_status(); | ||
| 228 | } | ||
| 229 | |||
| 230 | $( 'body' ).on( 'blur', '#wc-rbp-product-editor :input', function() { | ||
| 231 | $.WCRBP.render_price_status(); | ||
| 232 | } ); | ||
| 233 | |||
| 234 | $( "body" ).on( "click", 'div#wc-rbp-product-editor #wc_rbp_update_price', $.WCRBP.action_save_product_prices ); | ||
| 235 | $( "body" ) | ||
| 236 | .on( "click", 'div#wc-rbp-product-editor #wc_rbp_clear_trasient', $.WCRBP.action_clear_product_prices ); | ||
| 237 | |||
| 238 | }; | ||
| 239 | |||
| 240 | /** | ||
| 241 | * Internal Functions | ||
| 242 | */ | ||
| 243 | $.fn.wcrbp_checkbox = function() { | ||
| 244 | return this.each( function() { | ||
| 245 | var $this = $( this ), | ||
| 246 | size = $this.attr( 'data-size' ), | ||
| 247 | color = $this.attr( 'data-color' ), | ||
| 248 | secondaryColor = $this.attr( 'data-secondaryColor' ), | ||
| 249 | jackColor = $this.attr( "data-jackColor" ), | ||
| 250 | jackSecondaryColor = $this.attr( "data-jackSecondaryColor" ), | ||
| 251 | className = $this.attr( "data-className" ), | ||
| 252 | disabled = $this.attr( 'data-disabled' ), | ||
| 253 | disabledOpacity = $this.attr( "data-disabledOpacity" ), | ||
| 254 | speed = $this.attr( "data-speed" ); | ||
| 255 | |||
| 256 | new Switchery( this, { | ||
| 257 | size: size, | ||
| 258 | color: color, | ||
| 259 | secondaryColor: secondaryColor, | ||
| 260 | jackColor: jackColor, | ||
| 261 | jackSecondaryColor: jackSecondaryColor, | ||
| 262 | className: className, | ||
| 263 | disabled: disabled, | ||
| 264 | disabledOpacity: disabledOpacity, | ||
| 265 | speed: speed | ||
| 266 | } ); | ||
| 267 | |||
| 268 | |||
| 269 | } ); | ||
| 270 | }; | ||
| 271 | |||
| 272 | $( document ).ready( function() { | ||
| 273 | $.WCRBP.basic_init_metabox(); | ||
| 274 | } ); | ||
| 275 | |||
| 276 | $( window ).load( function() { | ||
| 277 | if( $( '#wc-rbp-product-editor' ).size() > 0 ) { | ||
| 278 | $.WCRBP.move_selectbox_metabox(); | ||
| 279 | $.WCRBP.unblock( $( 'div#wc-rbp-product-editor div.inside' ) ); | ||
| 280 | } | ||
| 281 | } ) | ||
| 282 | |||
| 283 | } )( jQuery, window, document ); | ||
| 284 | |||
| 285 |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | ; | ||
| 2 | ( function ($, window, document, undefined) { | ||
| 3 | 'use strict'; | ||
| 4 | |||
| 5 | $.WCRBP_SETTINGS = $.WCRBP_SETTINGS || {}; | ||
| 6 | |||
| 7 | $.WCRBP_SETTINGS.addons_html = ''; | ||
| 8 | |||
| 9 | $.WCRBP_SETTINGS.http_reffer = ''; | ||
| 10 | |||
| 11 | $.WCRBP_SETTINGS.handle_settings_page_url = function () { | ||
| 12 | var id = window.location.hash; | ||
| 13 | jQuery('.wc_rbp_settings_submenu a').removeClass('current'); | ||
| 14 | jQuery('.wc_rbp_settings_submenu a[href="' + id + '" ]').addClass('current'); | ||
| 15 | if ( id == '' ) { | ||
| 16 | jQuery('.wc_rbp_settings_submenu a:first').addClass('current'); | ||
| 17 | id = jQuery('.wc_rbp_settings_submenu a:first').attr('href'); | ||
| 18 | } | ||
| 19 | $.WCRBP_SETTINGS.http_reffer = jQuery('input[name=_wp_http_referer').val(); | ||
| 20 | |||
| 21 | $.WCRBP_SETTINGS.show_settings(id); | ||
| 22 | } | ||
| 23 | |||
| 24 | $.WCRBP_SETTINGS.show_settings = function (elem) { | ||
| 25 | jQuery('div.wc_rbp_settings_content').hide(); | ||
| 26 | elem = elem.replace('#', '#settings_'); | ||
| 27 | jQuery(elem).show(); | ||
| 28 | } | ||
| 29 | |||
| 30 | $.WCRBP_SETTINGS.settings_click_handler = function () { | ||
| 31 | var id = jQuery(this).attr('href'); | ||
| 32 | jQuery('.wc_rbp_settings_submenu a').removeClass('current'); | ||
| 33 | jQuery(this).addClass('current'); | ||
| 34 | $.WCRBP_SETTINGS.show_settings(id); | ||
| 35 | jQuery('input[name=_wp_http_referer').val($.WCRBP_SETTINGS.http_reffer + id); | ||
| 36 | } | ||
| 37 | |||
| 38 | $.WCRBP_SETTINGS.handle_activate_deactivate_addons = function (elem, $class) { | ||
| 39 | if ( typeof ( $class ) === 'undefined' ) $class = '.wc-rbp-deactivate-now'; | ||
| 40 | var clicked = elem; | ||
| 41 | var slug = elem.parent().attr('data-pluginslug'); | ||
| 42 | var parent_div = '.plugin-card-' + slug; | ||
| 43 | var height = jQuery(parent_div).innerHeight(); | ||
| 44 | var width = jQuery(parent_div).innerWidth(); | ||
| 45 | jQuery(parent_div + ' .wc_rbp_ajax_overlay').css('height', height + 'px').css('width', width + 'px').fadeIn(); | ||
| 46 | clicked.attr('disabled', 'disable'); | ||
| 47 | var link = clicked.attr('href'); | ||
| 48 | jQuery.ajax({ | ||
| 49 | method: 'GET', | ||
| 50 | url: link, | ||
| 51 | }).done(function (response) { | ||
| 52 | var status = response.success; | ||
| 53 | jQuery(parent_div + ' .wc_rbp_ajax_overlay').fadeOut(); | ||
| 54 | clicked.removeAttr('disabled'); | ||
| 55 | if ( status ) { | ||
| 56 | clicked.hide(); | ||
| 57 | jQuery(parent_div).find($class).fadeIn(); | ||
| 58 | } | ||
| 59 | |||
| 60 | jQuery(parent_div).find('.wc_rbp_ajax_response').hide().html(response.data.msg).fadeIn(function () { | ||
| 61 | setTimeout(function () { | ||
| 62 | jQuery(parent_div).find('.wc_rbp_ajax_response').fadeOut(); | ||
| 63 | }, 5000); | ||
| 64 | }); | ||
| 65 | |||
| 66 | jQuery.ajax({ | ||
| 67 | method: 'GET', | ||
| 68 | url: ajaxurl + '?action=wc_rbp_get_addons_html', | ||
| 69 | }).done(function (response) { | ||
| 70 | addons_html = jQuery(response); | ||
| 71 | }); | ||
| 72 | |||
| 73 | }); | ||
| 74 | } | ||
| 75 | |||
| 76 | |||
| 77 | $(document).ready(function () { | ||
| 78 | if ( jQuery('div.wc_rbp_addon_listing').size() > 0 ) { | ||
| 79 | jQuery('p.submit').remove(); | ||
| 80 | } | ||
| 81 | |||
| 82 | jQuery('select.wc-rbp-enhanced-select').selectize({ | ||
| 83 | plugins: ['remove_button', 'restore_on_backspace', 'drag_drop'], | ||
| 84 | persist: false, | ||
| 85 | create: true, | ||
| 86 | }); | ||
| 87 | |||
| 88 | jQuery('.wc_rbp_settings_submenu a').click($.WCRBP_SETTINGS.settings_click_handler); | ||
| 89 | |||
| 90 | if ( jQuery('.wc_rbp_settings_submenu').size() > 0 ) { | ||
| 91 | $.WCRBP_SETTINGS.handle_settings_page_url(); | ||
| 92 | } | ||
| 93 | |||
| 94 | jQuery('.wc_rbp_addon_listing').on('click', '.wc-rbp-activate-now', function () { | ||
| 95 | $.WCRBP_SETTINGS.handle_activate_deactivate_addons(jQuery(this), '.wc-rbp-deactivate-now') | ||
| 96 | }); | ||
| 97 | |||
| 98 | jQuery('.wc_rbp_addon_listing').on('click', '.wc-rbp-deactivate-now', function () { | ||
| 99 | $.WCRBP_SETTINGS.handle_activate_deactivate_addons(jQuery(this), '.wc-rbp-activate-now') | ||
| 100 | }); | ||
| 101 | |||
| 102 | $.WCRBP_SETTINGS.addons_html = jQuery('.wc_rbp_addon_listing').clone(); | ||
| 103 | |||
| 104 | jQuery('ul.wc_rbp_addons_category li a:first').addClass('current'); | ||
| 105 | |||
| 106 | jQuery('ul.wc_rbp_addons_category li a').click(function () { | ||
| 107 | var cat = jQuery(this).attr('data-category'); | ||
| 108 | var NewDis = 'div.wc-rbp-addon-' + cat; | ||
| 109 | jQuery('ul.wc_rbp_addons_category li a').removeClass('current'); | ||
| 110 | jQuery(this).addClass('current'); | ||
| 111 | jQuery('.wc_rbp_addon_listing').html($.WCRBP_SETTINGS.addons_html.find(NewDis).clone()); | ||
| 112 | }); | ||
| 113 | |||
| 114 | jQuery('ul.wc_rbp_addons_category li a').each(function () { | ||
| 115 | var category = jQuery(this).attr('data-category'); | ||
| 116 | var catCount = jQuery('.wc-rbp-addon-' + category).size(); | ||
| 117 | jQuery(this).append(' <span class="catCount"> (' + catCount + ') </span>'); | ||
| 118 | |||
| 119 | }); | ||
| 120 | |||
| 121 | jQuery('div.addons-search-form input.wp-filter-search').keyup(function () { | ||
| 122 | var val = jQuery(this).val(); | ||
| 123 | var html_source = $.WCRBP_SETTINGS.addons_html.clone(); | ||
| 124 | if ( val == '' ) { | ||
| 125 | jQuery('.wc_rbp_addon_listing').html(html_source); | ||
| 126 | jQuery('.wc-rbp-addon-all').show(); | ||
| 127 | } else { | ||
| 128 | html_source = jQuery(html_source).find(".plugin-card:contains('" + val + "')").not().remove(); | ||
| 129 | jQuery('.wc_rbp_addon_listing').html(html_source); | ||
| 130 | } | ||
| 131 | }) | ||
| 132 | |||
| 133 | }); | ||
| 134 | |||
| 135 | } )(jQuery, window, document); |
| 1 | !function(t,s,i,a){function e(s,i){this.element=t(s),this.$elem=t(this.element),this.settings=t.extend({},l,i),this._defaults=l,this._name=n,this.init()}var n="pwstabs",l={effect:"scale",defaultTab:1,containerWidth:"100%",tabsPosition:"horizontal",horizontalPosition:"top",verticalPosition:"left",responsive:!1,theme:"",rtl:!1};e.prototype={init:function(){var i=["scale","slideleft","slideright","slidetop","slidedown","none"],a=this.$elem,e=a.children("[data-pws-tab]");a.addClass("pws_tabs_list"),a.wrap('<div class="pws_tabs_container"></div>');var n=a.closest(".pws_tabs_container");if("100%"!==this.settings.containerWidth&&n.css("width",this.settings.containerWidth),"vertical"==this.settings.tabsPosition){if(n.closest(".pws_tab_single").length){var l=n.closest(".pws_tab_single").innerWidth();n.css("width",l)}"left"==this.settings.verticalPosition?n.addClass("pws_tabs_vertical pws_tabs_vertical_left"):n.addClass("pws_tabs_vertical pws_tabs_vertical_right")}else"top"==this.settings.horizontalPosition?n.addClass("pws_tabs_horizontal pws_tabs_horizontal_top"):n.addClass("pws_tabs_horizontal pws_tabs_horizontal_bottom");this.settings.rtl&&n.addClass("pws_tabs_rtl"),"none"==this.settings.effect&&n.addClass("pws_tabs_noeffect"),this.settings.theme&&n.addClass(this.settings.theme),t.inArray(this.settings.effect,i)>=0?n.addClass("pws_"+this.settings.effect):n.addClass("pws_scale"),e.addClass("pws_hide").hide(),"vertical"==this.settings.tabsPosition?"left"==this.settings.verticalPosition?n.prepend('<ul class="pws_tabs_controll"></ul>'):n.append('<ul class="pws_tabs_controll"></ul>'):"top"==this.settings.horizontalPosition?n.prepend('<ul class="pws_tabs_controll"></ul>'):n.append('<ul class="pws_tabs_controll"></ul>');var d=n.children(".pws_tabs_controll"),o=1;e.each(function(){t(this).attr("data-pws-tab-id",o);var s=t(this).data("pws-tab"),i=t(this).data("pws-tab-name");d.append('<li><a data-tab-id="'+s+'">'+i+"</a></li>"),t(this).addClass("pws_tab_single"),o++});var h=d.find("a"),p=d.find("li"),r=a.children('[data-pws-tab-id="'+this.settings.defaultTab+'"]');if(a.children("[data-pws-tab-icon]").each(function(){var s=t(this).attr("data-pws-tab"),i=t(this).attr("data-pws-tab-name"),a=t(this).attr("data-pws-tab-icon");""==i&&d.find('[data-tab-id="'+s+'"]').addClass("pws_tab_noname"),d.find('[data-tab-id="'+s+'"]').prepend('<i class="fa '+a+'"></i>')}),"vertical"==this.settings.tabsPosition){var _=n.innerWidth()/450,c=parseInt(h.css("font-size"))/_,w=parseInt(h.css("padding-left"))+parseInt(h.css("padding-right")),u=h.html().length*c+w,b=d.outerHeight(),f=n.outerWidth()-u,v=a.outerHeight();d.width(u),a.outerWidth(f),b>v&&a.css("min-height",b)}if(r.addClass("pws_show").show(),d.find('[data-tab-id="'+r.data("pws-tab")+'"]').addClass("pws_tab_active"),h.on("click",function(s){s.preventDefault(),h.removeClass("pws_tab_active"),t(this).addClass("pws_tab_active");var i=t(this).data("tab-id"),n=a.children('[data-pws-tab="'+i+'"]');e.removeClass("pws_show"),setTimeout(function(){e.hide(),n.show()},400),setTimeout(function(){n.addClass("pws_show")},450)}),this.settings.responsive){n.addClass("pws_tabs_responsive");var g=parseInt(d.children("li").length),m=100/g,C=Math.max.apply(null,p.map(function(){return t(this).height()}).get());t(s).on("resize load",{pluginSettings:this.settings},function(i){var e=i.data.pluginSettings,l=e.tabsPosition,o=e.containerWidth;t(s).width()<=960&&(n.width(""),p.css("width",m+"%"),h.each(function(){t(this).height(C)}),"vertical"==l&&(d.width(""),a.width(""),a.css("min-height",""),a.height(r.height()))),t(s).width()<=600?(n.find(".pws_responsive_small_menu").length<1&&t('<div class="pws_responsive_small_menu"><a data-visible="0"><i class="fa fa-bars"></i></a></div>').insertBefore(d),d.addClass("pws_tabs_menu_popup"),h.height(""),p.width(""),n.find("ul.pws_tabs_menu_popup").hide(),n.find(".pws_responsive_small_menu a").click(function(s){s.preventDefault(),"0"==t(this).attr("data-visible")?(n.find("ul.pws_tabs_menu_popup").show(),t(this).attr("data-visible","1")):(n.find("ul.pws_tabs_menu_popup").hide(),t(this).attr("data-visible","0"))}),n.find("ul.pws_tabs_menu_popup li a").on("click",function(s){s.preventDefault(),t(this).closest(".pws_tabs_menu_popup").hide(),n.find(".pws_responsive_small_menu a").attr("data-visible","0")})):t(s).width()>960?(n.css("width",o),p.width(""),h.height(""),n.find(".pws_responsive_small_menu").remove(),d.removeClass("pws_tabs_menu_popup"),d.show()):t(s).width()>600&&(n.find(".pws_responsive_small_menu").remove(),d.removeClass("pws_tabs_menu_popup"),d.show(),h.on("click",function(s){s.preventDefault(),t(this).parent().parent().show()}))})}}},t.fn[n]=function(t){return this.each(function(){new e(this,t)})}}(jQuery,window,document); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
File mode changed
No preview for this file type
wp-content/plugins/woocommerce-role-based-price/languages/woocommerce-role-based-price.pot
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | |||
| 3 | if( ! function_exists('wc_rbp_update_acs_role_based_price') ) { | ||
| 4 | /** | ||
| 5 | * Updates Products Role Based Price Array In DB | ||
| 6 | * | ||
| 7 | * @param int $post_id Post ID To Update | ||
| 8 | * @param array $price_array Price List | ||
| 9 | * | ||
| 10 | * @return boolean [[Description]] | ||
| 11 | */ | ||
| 12 | function wc_rbp_update_acs_role_based_price($post_id, $price_array) { | ||
| 13 | update_post_meta($post_id, '_acs_role_based_price', $price_array); | ||
| 14 | return TRUE; | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | if( ! function_exists('wc_rbp_get_acs_product_price') ) { | ||
| 19 | |||
| 20 | /** | ||
| 21 | * Gets Product price from DB | ||
| 22 | * #TODO Integrate Wth product_rbp_price function to make it faster | ||
| 23 | */ | ||
| 24 | function wc_rbp_get_acs_product_price($post_id, $supress_filter = FALSE) { | ||
| 25 | $price = get_post_meta($post_id, '_acs_role_based_price'); | ||
| 26 | |||
| 27 | if( ! empty($price) ) { | ||
| 28 | $price = $price[0]; | ||
| 29 | } else if( empty($price) ) { | ||
| 30 | $price = array(); | ||
| 31 | } | ||
| 32 | if( ! $supress_filter ) | ||
| 33 | $price = apply_filters('wc_rbp_product_acs_prices', $price); | ||
| 34 | |||
| 35 | return $price; | ||
| 36 | } | ||
| 37 | |||
| 38 | } | ||
| 39 | |||
| 40 | if( ! function_exists('product_acs_rbp_price') ) { | ||
| 41 | /** | ||
| 42 | * Gets product price from DB | ||
| 43 | */ | ||
| 44 | function product_acs_rbp_price($post_id) { | ||
| 45 | $price = wc_rbp_product_variable($post_id, 'wc_rbp_acs', 'wc_rbp_get_acs_product_price'); | ||
| 46 | return $price; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | if( ! function_exists('wc_rbp_acs_price') ) { | ||
| 51 | /** | ||
| 52 | * Returns Price Based On Give Value | ||
| 53 | * | ||
| 54 | * @role : enter role slug / use all to get all roles values | ||
| 55 | * @price : use selling_price / regular_price or use all to get all values for the given role | ||
| 56 | */ | ||
| 57 | function wc_rbp_acs_price($post_id, $role, $currency, $price = 'regular_price', $args = array()) { | ||
| 58 | $dbprice = product_acs_rbp_price($post_id); | ||
| 59 | |||
| 60 | $return = FALSE; | ||
| 61 | |||
| 62 | if( $price == 'all' && $role == 'all' ) { | ||
| 63 | $return = $dbprice; | ||
| 64 | } else if( $price == 'all' && $role !== 'all' ) { | ||
| 65 | if( isset($dbprice[$role]) ) { | ||
| 66 | $return = $dbprice[$role]; | ||
| 67 | } | ||
| 68 | } else if( $price == 'currency' && $role !== 'all' ) { | ||
| 69 | if( isset($dbprice[$role]) ) { | ||
| 70 | $return = $dbprice[$role][$currency]; | ||
| 71 | } | ||
| 72 | } else if( isset($dbprice[$role][$currency][$price]) ) { | ||
| 73 | $return = $dbprice[$role][$currency][$price]; | ||
| 74 | } | ||
| 75 | |||
| 76 | |||
| 77 | $return = apply_filters('wc_rbp_product_acs_price', $return, $role, $price, $post_id, $args); | ||
| 78 | |||
| 79 | return $return; | ||
| 80 | } | ||
| 81 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/plugins/aelia-currencyswitcher-integration/icon.jpg
0 → 100644
48.9 KB
| 1 | <div class="wc_rbp_popup_section acs_popup_section"> | ||
| 2 | |||
| 3 | <div class="wc_rbp_pop_field"><h3><?php _e('Aelia Currency Switcher', WC_RBP_TXT); ?></h3></div> | ||
| 4 | |||
| 5 | <div class="wc_rbp_pop_field"> | ||
| 6 | <?php | ||
| 7 | $tabs = array(); | ||
| 8 | $content = array(); | ||
| 9 | $output_html = ''; | ||
| 10 | |||
| 11 | foreach( $allowed_currency as $currency ) { | ||
| 12 | if( $this->base_currency == $currency ) { | ||
| 13 | continue; | ||
| 14 | } | ||
| 15 | $symbol = get_woocommerce_currency_symbol($currency); | ||
| 16 | $symbol = ! empty($symbol) ? ' (' . $symbol . ') ' : ' (' . $currency . ') '; | ||
| 17 | |||
| 18 | $tabs[$tab_id . '-' . $currency] = array( 'title' => $currency . ' ' . $symbol ); | ||
| 19 | |||
| 20 | $output_html = '<div class="wc_rbp_price_container wc_rbp_popup_section wc_rbp_popup_section_' . $tab_id . '_' . $currency . '">'; | ||
| 21 | foreach( $allowed_price as $price ) { | ||
| 22 | $value = wc_rbp_acs_price($product_id, $tab_id, $currency, $price); | ||
| 23 | $text = __('Enter Product\'s %s For %s Currency', WC_RBP_TXT); | ||
| 24 | $field_id = 'wc_rbp_acs[' . $tab_id . '][' . $currency . '][' . $price . ']'; | ||
| 25 | $defaults = array( | ||
| 26 | 'type' => 'text', | ||
| 27 | 'label' => $ex_price[$price] . $symbol, | ||
| 28 | 'description' => sprintf($text, $ex_price[$price], $currency), | ||
| 29 | 'class' => array(), | ||
| 30 | 'label_class' => array(), | ||
| 31 | 'input_class' => array( 'wc_input_price', $price, 'wc_rbp_' . $price ), | ||
| 32 | 'return' => TRUE, | ||
| 33 | 'custom_attributes' => array(), | ||
| 34 | ); | ||
| 35 | |||
| 36 | $output_html .= '<div class="wc_rbp_pop_field_50 wc_rbp_pop_field_' . $price . '">'; | ||
| 37 | $output_html .= woocommerce_form_field($field_id, $defaults, $value); | ||
| 38 | $output_html .= '</div>'; | ||
| 39 | |||
| 40 | } | ||
| 41 | $output_html .= '</div>'; | ||
| 42 | $content[$tab_id . '-' . $currency] = $output_html; | ||
| 43 | } | ||
| 44 | |||
| 45 | echo wc_rbp_generate_tabs($tabs, $content, array( 'tab_style' => 'default' )); | ||
| 46 | ?> | ||
| 47 | </div> | ||
| 48 | |||
| 49 | </div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/woocommerce-role-based-price/plugins/price-add-to-cart-visibility/icon.png
0 → 100644
18.2 KB
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin Name: Price & Add To Cart Visibility | ||
| 4 | * Plugin URI: | ||
| 5 | * Version: 1.0 | ||
| 6 | * Description: Allows to hide products price & add to cart button based on the user roles. | ||
| 7 | * Author: Varun Sridharan | ||
| 8 | * Author URI: http://varunsridharan.in | ||
| 9 | * Last Update: 2016-03-04 | ||
| 10 | * Category: Tools | ||
| 11 | */ | ||
| 12 | |||
| 13 | |||
| 14 | if( ! defined('WC_RBP_PLUGIN') ) { | ||
| 15 | die; | ||
| 16 | } | ||
| 17 | |||
| 18 | class Price_add_to_cart_visibility_WC_RBP { | ||
| 19 | |||
| 20 | public function __construct() { | ||
| 21 | add_filter('wc_rbp_addon_sections', array( $this, 'add_settings_section' )); | ||
| 22 | add_filter('wc_rbp_addon_fields', array( $this, 'add_settings_fields' )); | ||
| 23 | add_filter('init', array( $this, 'check_remove_add_to_cart' ), 999); | ||
| 24 | add_filter('woocommerce_get_price_html', array( $this, 'remove_price' ), 999, 2); | ||
| 25 | } | ||
| 26 | |||
| 27 | |||
| 28 | public function check_remove_add_to_cart() { | ||
| 29 | $current_role = wc_rbp_get_current_user(); | ||
| 30 | $resticted_role = wc_rbp_option('hide_product_addtocart'); | ||
| 31 | $variable_status = wc_rbp_option('hide_variable_product'); | ||
| 32 | |||
| 33 | if( empty($resticted_role) ) { | ||
| 34 | return; | ||
| 35 | } | ||
| 36 | if( in_array($current_role, $resticted_role) ) { | ||
| 37 | add_filter('woocommerce_loop_add_to_cart_link', array( &$this, 'remove_add_to_cart_link' ), 99); | ||
| 38 | remove_action('woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30); | ||
| 39 | if( $variable_status ) { | ||
| 40 | remove_action('woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30); | ||
| 41 | } else { | ||
| 42 | remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | public function remove_add_to_cart_link($link) { | ||
| 48 | return ''; | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | public function remove_price($price) { | ||
| 53 | $current_role = wc_rbp_get_current_user(); | ||
| 54 | $resticted_role = wc_rbp_option('hide_product_price'); | ||
| 55 | |||
| 56 | if( ! empty($resticted_role) ) { | ||
| 57 | if( in_array($current_role, $resticted_role) ) { | ||
| 58 | $price_notice = wc_rbp_option('pv_custom_message'); | ||
| 59 | $price_notice = apply_filters('wc_rbp_price_visibility_custom_price_message', $price_notice, $current_role); | ||
| 60 | if( ! empty($price_notice) ) { | ||
| 61 | $symbol = get_woocommerce_currency_symbol(); | ||
| 62 | $price_notice = str_replace('[currency]', $symbol, $price_notice); | ||
| 63 | return $price_notice; | ||
| 64 | } | ||
| 65 | return ''; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | return $price; | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | public function add_settings_fields($fields) { | ||
| 74 | $fields['price_visibility'][] = array( | ||
| 75 | 'id' => WC_RBP_DB . 'hide_product_price', | ||
| 76 | 'multiple' => 'true', | ||
| 77 | 'type' => 'select', | ||
| 78 | 'label' => __('Hide Price For', WC_RBP_TXT), | ||
| 79 | 'desc' => __('Product Price will be hidden for the selected user roles', WC_RBP_TXT), | ||
| 80 | 'options' => wc_rbp_get_user_roles_selectbox(), | ||
| 81 | 'attr' => array( | ||
| 82 | 'class' => 'wc-rbp-enhanced-select', | ||
| 83 | 'multiple' => 'multiple', | ||
| 84 | ), | ||
| 85 | ); | ||
| 86 | |||
| 87 | $fields['price_visibility'][] = array( | ||
| 88 | 'id' => WC_RBP_DB . 'hide_product_addtocart', | ||
| 89 | 'multiple' => 'true', | ||
| 90 | 'type' => 'select', | ||
| 91 | 'label' => __('Hide Add To Cart Button', WC_RBP_TXT), | ||
| 92 | 'desc' => __('Product Add To Cart Button will be hidden for the selected user roles', WC_RBP_TXT), | ||
| 93 | 'options' => wc_rbp_get_user_roles_selectbox(), | ||
| 94 | 'attr' => array( | ||
| 95 | 'class' => 'wc-rbp-enhanced-select', | ||
| 96 | 'multiple' => 'multiple', | ||
| 97 | ), | ||
| 98 | ); | ||
| 99 | |||
| 100 | $fields['price_visibility'][] = array( | ||
| 101 | 'id' => WC_RBP_DB . 'hide_variable_product', | ||
| 102 | 'type' => 'checkbox', | ||
| 103 | 'label' => __('Hide Product Variations', WC_RBP_TXT), | ||
| 104 | 'desc' => __('if checked Variable product variation will be hidden from product page ', WC_RBP_TXT), | ||
| 105 | 'attr' => array( 'class' => 'wc_rbp_checkbox', ), | ||
| 106 | ); | ||
| 107 | |||
| 108 | |||
| 109 | $fields['price_visibility'][] = array( | ||
| 110 | 'id' => WC_RBP_DB . 'pv_custom_message', | ||
| 111 | 'value' => html_entity_decode(wc_rbp_option('pv_custom_message')), | ||
| 112 | 'type' => 'richtext', | ||
| 113 | 'richtext_settings' => array( 'textarea_rows' => 5 ), | ||
| 114 | 'label' => __('Custom Message', WC_RBP_TXT), | ||
| 115 | 'desc' => __('Used when product price is hidden.. use <code>[currency]</code> to get current store currency', WC_RBP_TXT), | ||
| 116 | 'attr' => array( 'class' => 'wc_rbp_checkbox', ), | ||
| 117 | ); | ||
| 118 | |||
| 119 | return $fields; | ||
| 120 | } | ||
| 121 | |||
| 122 | public function add_settings_section($section) { | ||
| 123 | $c_section = array(); | ||
| 124 | $c_section['id'] = 'price_visibility'; | ||
| 125 | $c_section['title'] = __('Price & AddToCart Visibility', WC_RBP_TXT); | ||
| 126 | $c_section['desc'] = __('Hide Product Price & Add To Cart button based on users role and set custom messsage to show if price is hidden', WC_RBP_TXT); | ||
| 127 | $section[] = $c_section; | ||
| 128 | return $section; | ||
| 129 | } | ||
| 130 | |||
| 131 | } | ||
| 132 | |||
| 133 | return new Price_add_to_cart_visibility_WC_RBP; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
764 KB
425 KB
324 KB
360 KB
2.36 MB
34.7 KB
wp-content/plugins/woocommerce-role-based-price/plugins/wc-product-exporter/wc-product-exporter.php
0 → 100644
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin Name: WooCommerce Product Export | ||
| 4 | * Plugin URI: | ||
| 5 | * Version: 1.0 | ||
| 6 | * Description: This Addon Integration With Default Product Exporter In WooCommerce And Provides Options To Export Role Based Prices | ||
| 7 | * Author: Varun Sridharan | ||
| 8 | * Author URI: http://varunsridharan.in | ||
| 9 | * Last Update: 2017-07-07 | ||
| 10 | * Category: Tools,Price Export | ||
| 11 | */ | ||
| 12 | |||
| 13 | if( ! defined('WC_RBP_PLUGIN') ) { | ||
| 14 | die; | ||
| 15 | } | ||
| 16 | |||
| 17 | class wc_product_price_exporter { | ||
| 18 | |||
| 19 | public function __construct() { | ||
| 20 | $this->is_wcrbp_export = FALSE; | ||
| 21 | $this->key_vals(); | ||
| 22 | add_filter("woocommerce_product_export_product_default_columns", array( $this, 'add_option' )); | ||
| 23 | add_filter("woocommerce_product_export_row_data", array( $this, 'add_wcrbp_prices' ), 1, 2); | ||
| 24 | add_action("wp_ajax_woocommerce_do_ajax_product_export", array( $this, 'check_wcrbp_export' ), 1); | ||
| 25 | } | ||
| 26 | |||
| 27 | public function key_vals() { | ||
| 28 | $allowed_user_roles = wc_rbp_allowed_roles(); | ||
| 29 | $allowed_prices = wc_rbp_allowed_price(); | ||
| 30 | $active_cols = array( 'wcrbp_status' => '' ); | ||
| 31 | $user_roles = array(); | ||
| 32 | foreach( $allowed_user_roles as $role_id ) { | ||
| 33 | if( ! isset($user_roles['wcrbp_' . $role_id]) ) { | ||
| 34 | $user_roles['wcrbp_' . $role_id] = array(); | ||
| 35 | } | ||
| 36 | foreach( $allowed_prices as $price_id ) { | ||
| 37 | if( ! isset($active_cols['wcrbp_' . $role_id . '_' . $price_id]) ) { | ||
| 38 | $user_roles['wcrbp_' . $role_id]['wcrbp_' . $role_id . '_' . $price_id] = ''; | ||
| 39 | $active_cols['wcrbp_' . $role_id . '_' . $price_id] = array( 'role' => $role_id, | ||
| 40 | 'price' => $price_id, | ||
| 41 | ); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | $this->active_cols = $active_cols; | ||
| 47 | $this->user_roles = $user_roles; | ||
| 48 | return $this->active_cols; | ||
| 49 | } | ||
| 50 | |||
| 51 | public function check_wcrbp_export() { | ||
| 52 | |||
| 53 | if( isset($_POST['selected_columns']) ) { | ||
| 54 | if( is_array($_POST['selected_columns']) ) { | ||
| 55 | if( in_array('wcrbp_price', $_POST['selected_columns']) ) { | ||
| 56 | $this->remove_post_data('wcrbp_price'); | ||
| 57 | $_POST['selected_columns'] = array_merge($_POST['selected_columns'], array_keys($this->key_vals())); | ||
| 58 | $this->is_wcrbp_export = TRUE; | ||
| 59 | |||
| 60 | } else { | ||
| 61 | foreach( array_keys($this->user_roles) as $role ) { | ||
| 62 | if( in_array($role, $_POST['selected_columns']) ) { | ||
| 63 | $this->remove_post_data($role); | ||
| 64 | $_POST['selected_columns'] = array_merge($_POST['selected_columns'], array_keys($this->user_roles[$role])); | ||
| 65 | $this->is_wcrbp_export = TRUE; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | if( $this->is_wcrbp_export ) { | ||
| 73 | add_filter("woocommerce_product_export_column_names", array( $this, 'custom_col' )); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | public function remove_post_data($key) { | ||
| 78 | foreach( $_POST['selected_columns'] as $id => $vl ) { | ||
| 79 | if( $vl == $key ) { | ||
| 80 | unset($_POST['selected_columns'][$id]); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | public function add_wcrbp_prices($row, $product) { | ||
| 86 | if( $this->is_wcrbp_export ) { | ||
| 87 | $prices = wc_rbp_price($product->get_id(), 'all', 'all'); | ||
| 88 | if( isset($row['wcrbp_status']) ) | ||
| 89 | $row['wcrbp_status'] = wc_rbp_product_status($product->get_id(), TRUE); | ||
| 90 | |||
| 91 | if( ! empty($prices) ) { | ||
| 92 | foreach( $prices as $user => $price_types ) { | ||
| 93 | foreach( $price_types as $type => $price ) { | ||
| 94 | if( isset($row['wcrbp_' . $user . '_' . $type]) ) { | ||
| 95 | $row['wcrbp_' . $user . '_' . $type] = wc_format_localized_price($price); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | return $row; | ||
| 103 | } | ||
| 104 | |||
| 105 | public function custom_col($cols) { | ||
| 106 | $new_cols = $this->active_cols; | ||
| 107 | $allowed_user_roles = wc_rbp_allowed_roles(); | ||
| 108 | $allowed_prices = wc_rbp_allowed_price(); | ||
| 109 | foreach( $allowed_user_roles as $user_role_id ) { | ||
| 110 | foreach( $allowed_prices as $price ) { | ||
| 111 | if( ! isset($cols['wcrbp_' . $user_role_id . '_' . $price]) ) { | ||
| 112 | $cols['wcrbp_' . $user_role_id . '_' . $price] = $user_role_id . '_' . $price; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
| 116 | $cols['wcrbp_status'] = 'wcrbp_status'; | ||
| 117 | return $cols; | ||
| 118 | } | ||
| 119 | |||
| 120 | public function add_option($options) { | ||
| 121 | $options['wcrbp_price'] = __("Role Based Price For WooCommerce All", WC_RBP_TXT); | ||
| 122 | |||
| 123 | $allowed_user_roles = wc_rbp_allowed_roles(); | ||
| 124 | $user_roles = wc_rbp_get_wp_roles(); | ||
| 125 | $options['wcrbp_status'] = __("WC RBP Status", WC_RBP_TXT); | ||
| 126 | foreach( $user_roles as $user_role_id => $user_role_name ) { | ||
| 127 | if( in_array($user_role_id, $allowed_user_roles) ) { | ||
| 128 | if( ! isset($options['wcrbp_' . $user_role_id]) ) { | ||
| 129 | $options['wcrbp_' . $user_role_id] = __('WC Role Based ', WC_RBP_TXT) . $user_role_name['name'] . __(' Price ', WC_RBP_TXT); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | } | ||
| 133 | return $options; | ||
| 134 | } | ||
| 135 | } | ||
| 136 | |||
| 137 | return new wc_product_price_exporter; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
35.4 KB
wp-content/plugins/woocommerce-role-based-price/plugins/wc-product-importer/wc-product-importer.php
0 → 100644
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin Name: WooCommerce Product Importer | ||
| 4 | * Plugin URI: | ||
| 5 | * Version: 1.0 | ||
| 6 | * Description: This Addon Integration With Default Product Importer In WooCommerce And Provides Options To Import, Role Based Prices | ||
| 7 | * Author: Varun Sridharan | ||
| 8 | * Author URI: http://varunsridharan.in | ||
| 9 | * Last Update: 2017-07-07 | ||
| 10 | * Category: Tools,Price Import | ||
| 11 | */ | ||
| 12 | |||
| 13 | if( ! defined('WC_RBP_PLUGIN') ) { | ||
| 14 | die; | ||
| 15 | } | ||
| 16 | |||
| 17 | class wc_product_price_importer { | ||
| 18 | |||
| 19 | public function __construct() { | ||
| 20 | add_filter("woocommerce_csv_product_import_mapping_options", array( $this, 'add_import_options' )); | ||
| 21 | add_action("woocommerce_product_import_inserted_product_object", array( $this, 'save_price' ), 10, 2); | ||
| 22 | } | ||
| 23 | |||
| 24 | public function save_price($product, $data) { | ||
| 25 | $this->generate_options_data(); | ||
| 26 | $obj = $this->options_product_save; | ||
| 27 | $obk = array_keys($obj); | ||
| 28 | $final_price = array(); | ||
| 29 | $status = FALSE; | ||
| 30 | foreach( $data as $id => $value ) { | ||
| 31 | if( $id == 'wcrbp_status' ) { | ||
| 32 | if( $value == 'no' ) { | ||
| 33 | $status = FALSE; | ||
| 34 | } else if( $value == 'yes' ) { | ||
| 35 | $status = TRUE; | ||
| 36 | } else if( floatval($value) == 0 ) { | ||
| 37 | $status = FALSE; | ||
| 38 | } else if( floatval($value) == 1 ) { | ||
| 39 | $status = TRUE; | ||
| 40 | } | ||
| 41 | |||
| 42 | } else if( in_array($id, $obk) ) { | ||
| 43 | $attribute = $obj[$id]; | ||
| 44 | $role = $attribute['role']; | ||
| 45 | $price_type = $attribute['price']; | ||
| 46 | if( $value != '' ) { | ||
| 47 | $final_price[$role][$price_type] = wc_format_decimal($value); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | if( ! empty($final_price) ) | ||
| 52 | wc_rbp_update_role_based_price($product->get_id(), $final_price); | ||
| 53 | |||
| 54 | wc_rbp_update_role_based_price_status($product->get_id(), $status); | ||
| 55 | |||
| 56 | } | ||
| 57 | |||
| 58 | public function generate_options_data() { | ||
| 59 | if( isset($this->options_updated) ) { | ||
| 60 | return $this->options_updated; | ||
| 61 | } | ||
| 62 | $allowed_user_roles = wc_rbp_allowed_roles(); | ||
| 63 | $allowed_prices = wc_rbp_allowed_price(); | ||
| 64 | $options = array( "wcrbp_status" => __("Price Status") ); | ||
| 65 | $options2 = array( "wcrbp_status" => __("Price Status") ); | ||
| 66 | foreach( wc_rbp_get_wp_roles() as $role_id => $data ) { | ||
| 67 | if( in_array($role_id, $allowed_user_roles) ) { | ||
| 68 | foreach( $allowed_prices as $price_id ) { | ||
| 69 | $options[$role_id . '_' . $price_id] = ' WC Role Based ' . $data['name'] . ' - ' . wc_rbp_price_types($price_id); | ||
| 70 | $options2[$role_id . '_' . $price_id] = array( 'role' => $role_id, 'price' => $price_id ); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | $this->options_updated = $options; | ||
| 75 | $this->options_product_save = $options2; | ||
| 76 | return $options; | ||
| 77 | } | ||
| 78 | |||
| 79 | public function add_import_options($options) { | ||
| 80 | $options['wcrbp_options'] = array( | ||
| 81 | 'name' => __("Role Based Price For WooCommerce"), | ||
| 82 | 'options' => $this->generate_options_data(), | ||
| 83 | ); | ||
| 84 | return $options; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | return new wc_product_price_importer; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Summary (no period for file headers) | ||
| 4 | * | ||
| 5 | * Description. (use period) | ||
| 6 | * | ||
| 7 | * @link https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 8 | * @package Role Based Price For WooCommerce | ||
| 9 | * @subpackage Role Based Price For WooCommerce/core | ||
| 10 | * @since 3.0 | ||
| 11 | */ | ||
| 12 | if( ! defined('WP_UNINSTALL_PLUGIN') ) { | ||
| 13 | exit; | ||
| 14 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /** | ||
| 3 | * Plugin Name: Role Based Price For WooCommerce | ||
| 4 | * Plugin URI: https://wordpress.org/plugins/woocommerce-role-based-price/ | ||
| 5 | * Description: Sell product in different price for different user role based on your settings. | ||
| 6 | * Version: 3.3.6 | ||
| 7 | * Author: Varun Sridharan | ||
| 8 | * Author URI: http://varunsridharan.in | ||
| 9 | * License: GPL-2.0+ | ||
| 10 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt | ||
| 11 | * Text Domain: woocommerce-role-based-price | ||
| 12 | * Domain Path: /languages/ | ||
| 13 | */ | ||
| 14 | |||
| 15 | if ( ! defined( 'WPINC' ) ) { | ||
| 16 | die; | ||
| 17 | } | ||
| 18 | |||
| 19 | define( 'WC_RBP_FILE', plugin_basename( __FILE__ ) ); | ||
| 20 | define( 'WC_RBP_PATH', plugin_dir_path( __FILE__ ) ); # Plugin DIR | ||
| 21 | define( 'WC_RBP_INC', WC_RBP_PATH . 'includes/' ); # Plugin INC Folder | ||
| 22 | define( 'WC_RBP_DEPEN', 'woocommerce/woocommerce.php' ); | ||
| 23 | define( 'WC_RBP_VARIABLE_VERSION', '3.3.6' ); | ||
| 24 | register_activation_hook( __FILE__, 'wc_rbp_activate_plugin_name' ); | ||
| 25 | register_deactivation_hook( __FILE__, 'wc_rbp_deactivate_plugin_name' ); | ||
| 26 | register_deactivation_hook( WC_RBP_DEPEN, 'wc_rbp_dependency_plugin_deactivate' ); | ||
| 27 | |||
| 28 | |||
| 29 | /** | ||
| 30 | * The code that runs during plugin activation. | ||
| 31 | * This action is documented in includes/class-plugin-name-activator.php | ||
| 32 | */ | ||
| 33 | function wc_rbp_activate_plugin_name() { | ||
| 34 | require_once( WC_RBP_INC . 'helpers/class-activator.php' ); | ||
| 35 | woocommerce_role_based_price_Activator::activate(); | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * The code that runs during plugin deactivation. | ||
| 40 | * This action is documented in includes/class-plugin-name-deactivator.php | ||
| 41 | */ | ||
| 42 | function wc_rbp_deactivate_plugin_name() { | ||
| 43 | require_once( WC_RBP_INC . 'helpers/class-deactivator.php' ); | ||
| 44 | woocommerce_role_based_price_Deactivator::deactivate(); | ||
| 45 | } | ||
| 46 | |||
| 47 | |||
| 48 | /** | ||
| 49 | * The code that runs during plugin deactivation. | ||
| 50 | * This action is documented in includes/class-plugin-name-deactivator.php | ||
| 51 | */ | ||
| 52 | function wc_rbp_dependency_plugin_deactivate() { | ||
| 53 | require_once( WC_RBP_INC . 'helpers/class-deactivator.php' ); | ||
| 54 | woocommerce_role_based_price_Deactivator::dependency_deactivate(); | ||
| 55 | } | ||
| 56 | |||
| 57 | require_once( WC_RBP_INC . 'functions.php' ); | ||
| 58 | require_once( plugin_dir_path( __FILE__ ) . 'bootstrap.php' ); | ||
| 59 | |||
| 60 | if ( ! function_exists( 'woocommerce_role_based_price' ) ) { | ||
| 61 | function woocommerce_role_based_price() { | ||
| 62 | return woocommerce_role_based_price::get_instance(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | woocommerce_role_based_price(); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment