WC_Cart::show_shipping()
Sees if the customer has entered enough data to calculate shipping.
Method of the class: WC_Cart{}
Hooks from the method
Return
true|false
.
Usage
$WC_Cart = new WC_Cart(); $WC_Cart->show_shipping();
WC_Cart::show_shipping() WC Cart::show shipping code WC 9.8.2
public function show_shipping() { // If there are no shipping methods or no cart contents, no need to calculate shipping. if ( ! wc_shipping_enabled() || 0 === wc_get_shipping_method_count( true ) || ! $this->get_cart_contents() ) { return false; } if ( 'yes' === get_option( 'woocommerce_shipping_cost_requires_address' ) ) { $customer = $this->get_customer(); if ( ! $customer instanceof \WC_Customer || ! $customer->has_full_shipping_address() ) { return false; } } /** * Filter to allow plugins to prevent shipping calculations. * * @since 2.7.0 * * @param bool $ready Whether the cart is ready to calculate shipping. */ return apply_filters( 'woocommerce_cart_ready_to_calc_shipping', true ); }