Improve inline docs in calculate_shipping_for_package
This commit is contained in:
parent
7f78cc3acc
commit
5280ceb8d9
|
@ -226,7 +226,8 @@ class WC_Shipping {
|
|||
public function get_shipping_classes() {
|
||||
if ( empty( $this->shipping_classes ) ) {
|
||||
$classes = get_terms(
|
||||
'product_shipping_class', array(
|
||||
'product_shipping_class',
|
||||
array(
|
||||
'hide_empty' => '0',
|
||||
'orderby' => 'name',
|
||||
)
|
||||
|
@ -317,9 +318,12 @@ class WC_Shipping {
|
|||
unset( $package_to_hash['contents'][ $item_id ]['data'] );
|
||||
}
|
||||
|
||||
// Get rates stored in the WC session data for this package.
|
||||
$wc_session_key = 'shipping_for_package_' . $package_key;
|
||||
$stored_rates = WC()->session->get( $wc_session_key );
|
||||
|
||||
// Calculate the hash for this package so we can tell if it's changed since last calculation.
|
||||
$package_hash = 'wc_ship_' . md5( wp_json_encode( $package_to_hash ) . WC_Cache_Helper::get_transient_version( 'shipping' ) );
|
||||
$session_key = 'shipping_for_package_' . $package_key;
|
||||
$stored_rates = WC()->session->get( $session_key );
|
||||
|
||||
if ( ! is_array( $stored_rates ) || $package_hash !== $stored_rates['package_hash'] || 'yes' === get_option( 'woocommerce_shipping_debug_mode', 'no' ) ) {
|
||||
foreach ( $this->load_shipping_methods( $package ) as $shipping_method ) {
|
||||
|
@ -333,7 +337,8 @@ class WC_Shipping {
|
|||
|
||||
// Store in session to avoid recalculation.
|
||||
WC()->session->set(
|
||||
$session_key, array(
|
||||
$wc_session_key,
|
||||
array(
|
||||
'package_hash' => $package_hash,
|
||||
'rates' => $package['rates'],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue