PHP Class WC_Connect_Shipping_Method, woocommerce-connect-client

Inheritance: extends WC_Shipping_Method
Show file Open project: Automattic/woocommerce-connect-client Class Usage Examples

Protected Properties

Property Type Description
$api_client WC_Connect_API_Client
$logger WC_Connect_Logger
$service_schema A reference to a the fetched properties of the service
$service_settings_store WC_Connect_Service_Settings_Store

Public Methods

Method Description
__construct ( $id_or_instance_id = null )
admin_options ( )
calculate_shipping ( $package = [] )
format_rate_id ( $method_id, $instance, $rate_idx )
format_rate_title ( $rate_title )
get_api_client ( )
get_logger ( )
get_service_schema ( )
get_service_settings ( ) : object Returns the settings for this service (e.g. for use in the form or for sending to the rate request endpoint
get_service_settings_store ( )
is_valid_package_destination ( array $package ) : boolean Determine if a package's destination is valid enough for a rate quote.
set_api_client ( WC_Connect_API_Client $api_client )
set_last_request_failed ( $timestamp = null )
set_logger ( WC_Connect_Logger $logger )
set_service_schema ( $service_schema )
set_service_settings_store ( $service_settings_store )
update_last_rate_request_timestamp ( )

Protected Methods

Method Description
init_form_settings ( ) Restores any values persisted to the DB for this service instance and sets up title for WC core to work properly
log ( string | WP_Error $message, string $context = '' ) Logging helper.

Private Methods

Method Description
lookup_product ( $package, $product_id )

Method Details

__construct() public method

public __construct ( $id_or_instance_id = null )

admin_options() public method

public admin_options ( )

calculate_shipping() public method

public calculate_shipping ( $package = [] )

format_rate_id() public static method

public static format_rate_id ( $method_id, $instance, $rate_idx )

format_rate_title() public static method

public static format_rate_title ( $rate_title )

get_api_client() public method

public get_api_client ( )

get_logger() public method

public get_logger ( )

get_service_schema() public method

public get_service_schema ( )

get_service_settings() public method

Used by WC_Connect_Loader to embed the form schema in the page for JS to consume
public get_service_settings ( ) : object
return object

get_service_settings_store() public method

init_form_settings() protected method

Restores any values persisted to the DB for this service instance and sets up title for WC core to work properly
protected init_form_settings ( )

is_valid_package_destination() public method

Determine if a package's destination is valid enough for a rate quote.
public is_valid_package_destination ( array $package ) : boolean
$package array
return boolean

log() protected method

Avoids calling methods on an undefined object if no logger was injected during the init action in the constructor.
See also: WC_Connect_Logger::log()
protected log ( string | WP_Error $message, string $context = '' )
$message string | WP_Error
$context string

set_api_client() public method

public set_api_client ( WC_Connect_API_Client $api_client )
$api_client WC_Connect_API_Client

set_last_request_failed() public method

public set_last_request_failed ( $timestamp = null )

set_logger() public method

public set_logger ( WC_Connect_Logger $logger )
$logger WC_Connect_Logger

set_service_schema() public method

public set_service_schema ( $service_schema )

set_service_settings_store() public method

public set_service_settings_store ( $service_settings_store )

update_last_rate_request_timestamp() public method

Property Details

$api_client protected property

protected WC_Connect_API_Client $api_client
return WC_Connect_API_Client

$logger protected property

protected WC_Connect_Logger $logger
return WC_Connect_Logger

$service_schema protected property

A reference to a the fetched properties of the service
protected $service_schema

$service_settings_store protected property

protected WC_Connect_Service_Settings_Store $service_settings_store
return WC_Connect_Service_Settings_Store