Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks
AdditionalPayments{}
Payments Task
No Hooks.
Usage
$AdditionalPayments = new AdditionalPayments(); // use class methods
Methods
- public can_view()
- public get_content()
- public get_id()
- public get_time()
- public get_title()
- public static has_gateways()
- public is_complete()
Code of AdditionalPayments{} AdditionalPayments{} WC 6.6.1
class AdditionalPayments extends Payments { /** * ID. * * @return string */ public function get_id() { return 'payments'; } /** * Title. * * @return string */ public function get_title() { return __( 'Set up additional payment providers', 'woocommerce' ); } /** * Content. * * @return string */ public function get_content() { return __( 'Choose payment providers and enable payment methods at checkout.', 'woocommerce' ); } /** * Time. * * @return string */ public function get_time() { return __( '2 minutes', 'woocommerce' ); } /** * Task completion. * * @return bool */ public function is_complete() { return self::has_gateways(); } /** * Task visibility. * * @return bool */ public function can_view() { if ( ! Features::is_enabled( 'payment-gateway-suggestions' ) ) { // Hide task if feature not enabled. return false; } $woocommerce_payments = new WooCommercePayments(); if ( ! $woocommerce_payments->is_requested() || ! $woocommerce_payments->is_supported() || ! $woocommerce_payments->is_connected() ) { // Hide task if WC Pay is not installed via OBW, or is not connected, or the store is located in a country that is not supported by WC Pay. return false; } if ( $this->get_parent_id() === 'extended_two_column' && WooCommercePayments::is_connected() ) { return false; } return true; } /** * Check if the store has any enabled gateways. * * @return bool */ public static function has_gateways() { $gateways = WC()->payment_gateways->get_available_payment_gateways(); $enabled_gateways = array_filter( $gateways, function( $gateway ) { return 'yes' === $gateway->enabled && 'woocommerce_payments' !== $gateway->id; } ); return ! empty( $enabled_gateways ); } }