68% woo-conditional-payment-gateways

Code Review | WooCommerce Disable Payment Methods based on cart conditions

WordPress plugin WooCommerce Disable Payment Methods based on cart conditions scored68%from 54 tests.

About plugin

  • Plugin page: woo-conditional-p...
  • Plugin version: 1.16.0
  • PHP version: 7.4.16
  • WordPress compatibility: 3.0-6.2
  • WordPress version: 6.3.1
  • First release: Dec 25, 2018
  • Latest release: Jul 5, 2023
  • Number of updates: 60
  • Update frequency: every 27.6 days
  • Top authors: JoseVega (100%)

Code review

54 tests

User reviews

14 reviews

Install metrics

1,000+ active /25,014 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | It is important to correctly install your plugin, without throwing errors or notices
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.65MB] [CPU: ▲3.75ms] Passed 4 tests

This is a short check of server-side resources used by WooCommerce Disable Payment Methods based on cart conditions
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /4.11 ▲0.6543.96 ▼1.18
Dashboard /wp-admin3.98 ▲0.6755.20 ▲5.72
Posts /wp-admin/edit.php4.03 ▲0.6754.67 ▲8.21
Add New Post /wp-admin/post-new.php6.50 ▲0.61100.87 ▲7.28
Media Library /wp-admin/upload.php3.90 ▲0.6739.60 ▲3.18
Freemius Debug [v.2.5.10] /wp-admin/admin.php?page=freemius4.2739.79
Conditional Payment Methods /wp-admin/admin.php?page=wccpg_welcome_page3.9137.78
Conditional Payment Methods /wp-admin/admin.php?page=wccpg_whats_new3.8435.28

Server storage [IO: ▲3.73MB] [DB: ▲0.07MB] Passed 3 tests

Analyzing filesystem and database footprints of this plugin
The plugin installed successfully
Filesystem: 270 new files
Database: no new tables, 10 new options
New WordPress options
fs_debug_mode
db_upgraded
wccpg_welcome_redirect
fs_active_plugins
widget_theysaidso_widget
widget_recent-posts
widget_recent-comments
theysaidso_admin_options
fs_accounts
can_compress_scripts

Browser metrics Passed 4 tests

Checking browser requirements for WooCommerce Disable Payment Methods based on cart conditions
There were no issues detected in relation to browser resource usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,831 ▲4514.24 ▼0.092.11 ▲0.0932.63 ▼9.62
Dashboard /wp-admin2,215 ▲385.62 ▼0.0293.89 ▼1.1344.01 ▲2.00
Posts /wp-admin/edit.php2,121 ▲182.01 ▲0.0241.77 ▲2.4840.14 ▲5.81
Add New Post /wp-admin/post-new.php1,531 ▲523.30 ▲0.23682.17 ▲13.4959.80 ▲3.21
Media Library /wp-admin/upload.php1,420 ▲204.18 ▲0.0698.93 ▲1.7447.61 ▲7.62
Freemius Debug [v.2.5.10] /wp-admin/admin.php?page=freemius1,0821.6526.4728.54
Conditional Payment Methods /wp-admin/admin.php?page=wccpg_welcome_page7972.0324.1228.48
Conditional Payment Methods /wp-admin/admin.php?page=wccpg_whats_new7972.0323.8426.58

Uninstaller [IO: ▲0.00MB] [DB: ▲0.07MB] 50% from 4 tests

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
It is recommended to fix the following
  • Uninstall procedure had uncaught errors
    • > Notice in wp-content/plugins/woo-conditional-payment-gateways/vendor/freemius/includes/class-freemius.php+8486
    Undefined property: stdClass::$plugins
  • The uninstall procedure has failed, leaving 10 options in the database
    • widget_recent-posts
    • widget_recent-comments
    • wccpg_welcome_redirect
    • theysaidso_admin_options
    • widget_theysaidso_widget
    • fs_active_plugins
    • fs_accounts
    • can_compress_scripts
    • db_upgraded
    • fs_debug_mode

Smoke tests 50% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
These errors were triggered by the plugin
    • > GET request to /wp-admin/admin.php?page=wccpg_welcome_page
    • > Notice in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/views/page-template.php+18
    Undefined variable: content
    • > GET request to /wp-admin/admin.php?page=wccpg_whats_new
    • > Warning in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/index.php+169
    include(/1.16.0.php): failed to open stream: No such file or directory
    • > GET request to /wp-admin/admin.php?page=wccpg_whats_new
    • > Warning in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/index.php+169
    include(): Failed opening '/1.16.0.php' for inclusion (include_path='.:/usr/share/php')
    • > GET request to /wp-admin/admin.php?page=wccpg_whats_new
    • > Notice in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/index.php+171
    Undefined variable: items
    • > GET request to /wp-admin/admin.php?page=wccpg_whats_new
    • > Warning in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/index.php+187
    include(): Filename cannot be empty
    • > GET request to /wp-admin/admin.php?page=wccpg_whats_new
    • > Warning in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/index.php+187
    include(): Failed opening '' for inclusion (include_path='.:/usr/share/php')

SRP 50% from 2 tests

🔹 Tests weight: 20 | A shallow check of the single-responsibility principle; PHP files should perform no action - including output of placeholder text - and trigger no errors when accessed directly
Please take a closer look at the following
  • 15× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/woo-conditional-payment-gateways/modules/core/frontend/reload-checkout.php:7
    • > PHP Warning
      Use of undefined constant WCCPG_DIST_DIR - assumed 'WCCPG_DIST_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/woo-conditional-payment-gateways/inc/freemius-init.php on line 10
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/woo-conditional-payment-gateways/backend/premium-teasers.php:155
    • > PHP Warning
      require_once(WCCPG_DIST_DIR/vendor/freemius/start.php): failed to open stream: No such file or directory in wp-content/plugins/woo-conditional-payment-gateways/inc/freemius-init.php on line 10
    • > PHP Fatal error
      Uncaught Error: Call to undefined function __() in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/samples/email-optin-form.php:3
    • > PHP Fatal error
      require_once(): Failed opening required 'WCCPG_DIST_DIR/vendor/freemius/start.php' (include_path='.:/usr/share/php') in wp-content/plugins/woo-conditional-payment-gateways/inc/freemius-init.php on line 10
    • > PHP Fatal error
      Uncaught Error: Class 'WPCPG_Condition' not found in wp-content/plugins/woo-conditional-payment-gateways/modules/core/backend/conditions/cart/subtotal.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function WCCPG() in wp-content/plugins/woo-conditional-payment-gateways/modules/core/index.php:22
    • > PHP Warning
      Use of undefined constant WCCPG_TEXTDOMAIN - assumed 'WCCPG_TEXTDOMAIN' (this will throw an Error in a future version of PHP) in wp-content/plugins/woo-conditional-payment-gateways/modules/core/index.php on line 19
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_create_nonce() in wp-content/plugins/woo-conditional-payment-gateways/vendor/vg-plugin-sdk/views/page-template.php:5

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Everything seems fine on the user side

Optimizations

Plugin configuration 93% from 29 tests

readme.txt Passed 16 tests

The readme.txt file is important because it is parsed by WordPress.org for the public listing of your plugin
2 plugin tags: payment gateways, woocommerce

woo-conditional-payment-gateways/conditional-payment-gateways.php 85% from 13 tests

The main file in "WooCommerce Disable Payment Methods based on cart conditions" v. 1.16.0 serves as a complement to information provided in readme.txt and as the entry point to the plugin
The following require your attention:
  • Main file name: It is recommended to name the main PHP file as the plugin slug ("woo-conditional-payment-gateways.php" instead of "conditional-payment-gateways.php")
  • Requires at least: Required version must be the same as the one declared in readme.txt ("4.0" instead of "3.0")

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short glimpse at programming languages used with this plugin and a check that no dangerous files are present
Everything looks great! No dangerous files found in this plugin45,294 lines of code in 222 files:
LanguageFilesBlank linesComment linesLines of code
PHP1418,59517,38435,111
JavaScript632,5727339,674
CSS17660499
XML10010

PHP code 50% from 2 tests

An overview of cyclomatic complexity and code structure
Please fix the following
  • Please reduce cyclomatic complexity of classes to less than 1000 (currently 3,073)
Cyclomatic complexity
Average complexity per logical line of code0.62
Average class complexity72.45
▷ Minimum class complexity1.00
▷ Maximum class complexity3,073.00
Average method complexity4.37
▷ Minimum method complexity1.00
▷ Maximum method complexity94.00
Code structure
Namespaces0
Interfaces0
Traits2
Classes63
▷ Abstract classes34.76%
▷ Concrete classes6095.24%
▷ Final classes00.00%
Methods1,409
▷ Static methods21114.98%
▷ Public methods1,01471.97%
▷ Protected methods201.42%
▷ Private methods37526.61%
Functions107
▷ Named functions107100.00%
▷ Anonymous functions00.00%
Constants154
▷ Global constants10769.48%
▷ Class constants4730.52%
▷ Public constants47100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
3 PNG files occupy 0.07MB with 0.03MB in potential savings
Potential savings
Compression of 3 random PNG files using pngquant
FileSize - originalSize - compressedSavings
vendor/freemius/assets/img/plugin-icon.png9.16KB5.26KB▼ 42.58%
modules/core/assets/imgs/gateway-key.png49.85KB20.64KB▼ 58.59%
vendor/freemius/assets/img/theme-icon.png10.97KB5.78KB▼ 47.37%