code 17
-
This code snippet is failing, but has been working for over a year no issue until now. has there been any changes with code snippet? i have replaced the domain with DOMAINNAME. this error stops the cron job action_scheduler_run_queue from working.
any ideas?
‘PHP message: PHP Fatal error: Uncaught Error: Call to a member function get() on null in /home/DOMAINNAME.com.au/htdocs/wp-content/plugins/code-snippets/php/snippet-ops.php(505) : eval()’d code:17\nStack trace:\n#0 /home/DOMAINNAME.com.au/htdocs/wp-includes/class-wp-hook.php(308): bbloomer_gateway_disable_shipping_326()\n#1 /home/DOMAINNAME.com.au/htdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters()\n#2 /home/DOMAINNAME.com.au/htdocs/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php(163): apply_filters()\n#3 /home/DOMAINNAME.com.au/htdocs/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/services.php(1322): WC_Payment_Gateways->get_available_payment_gateways()\n#4 /home/DOMAINNAME.com.au/htdocs/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Dhii/Container/DelegatingContainer.php(117): WooCommerce\PayPalCommerce\WcGateway\WCGatewayModule::WooCommerce\PayPalCommerce\WcGateway\{closure}()\n#5 /home/DOMAINNAME.com.au/
Following is the code that has been working fine.
/** * @snippet Disable Payment Gateway For Specific Shipping Method * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=19867 * @author Rodolfo Melogli * @testedwith WooCommerce 3.2.6 */ if(!is_admin() ) add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_gateway_disable_shipping_326' ); function bbloomer_gateway_disable_shipping_326( $available_gateways ) { global $woocommerce; if ( !is_admin() ) { $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); $chosen_shipping = $chosen_methods[0]; if ( isset( $available_gateways['ppcp-gateway'] ) && 0 === strpos( $chosen_shipping, 'local_pickup' ) ) { unset( $available_gateways['ppcp-gateway'] ); } if ( isset( $available_gateways['afterpay'] ) && 0 === strpos( $chosen_shipping, 'local_pickup' ) ) { unset( $available_gateways['afterpay'] ); } if ( isset( $available_gateways['klarna_payments'] ) && 0 === strpos( $chosen_shipping, 'local_pickup' ) ) { unset( $available_gateways['klarna_payments'] ); } if ( isset( $available_gateways['cheque'] ) && 0 === strpos( $chosen_shipping, 'ozpost' ) ) { unset( $available_gateways['cheque'] ); } if ( isset( $available_gateways['cheque'] ) && 0 === strpos( $chosen_shipping, 'wf_australia_post' ) ) { unset( $available_gateways['cheque'] ); } if ( isset( $available_gateways['cheque'] ) && 0 === strpos( $chosen_shipping, 'wf_australia_mypost' ) ) { unset( $available_gateways['cheque'] ); } } return $available_gateways; }
- The topic ‘code 17’ is closed to new replies.