Merge branch 'trunk' into dev/pnpm-settings-tweaks

This commit is contained in:
Vladimir Reznichenko 2024-09-19 15:35:21 +02:00 committed by GitHub
commit af4d53f722
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 8 deletions

View File

@ -6,6 +6,7 @@
align-items: stretch;
margin: 0;
overflow-x: auto;
scrollbar-width: none;
}
.woocommerce-marketplace__category-item {
@ -132,15 +133,18 @@
top: 0;
bottom: 0;
height: 100%;
width: 50px;
width: 100px;
cursor: pointer;
}
.woocommerce-marketplace__category-navigation-button--prev {
background: linear-gradient(to right, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
left: 0;
text-align: left;
}
.woocommerce-marketplace__category-navigation-button--next {
background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
right: 0;
text-align: right;
}

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Fix marketplace category selector scrollbars and buttons

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Ensure session is loaded in cart functions to prevent fatal errors.

View File

@ -412,13 +412,13 @@ function wc_cart_round_discount( $value, $precision ) {
* @return string[]
*/
function wc_get_chosen_shipping_method_ids() {
$method_ids = array();
$chosen_methods = array();
if ( is_callable( array( WC()->session, 'get' ) ) ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods', array() );
if ( ! is_callable( array( WC()->session, 'get' ) ) ) {
return array();
}
$chosen_methods = WC()->session->get( 'chosen_shipping_methods', array() );
$method_ids = array();
foreach ( $chosen_methods as $chosen_method ) {
if ( ! is_string( $chosen_method ) ) {
continue;
@ -439,11 +439,15 @@ function wc_get_chosen_shipping_method_ids() {
* @return string|bool Either the chosen method ID or false if nothing is chosen yet.
*/
function wc_get_chosen_shipping_method_for_package( $key, $package ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
if ( ! is_callable( array( WC()->session, 'get' ) ) ) {
return false;
}
$chosen_methods = WC()->session->get( 'chosen_shipping_methods', array() );
$chosen_method = isset( $chosen_methods[ $key ] ) ? $chosen_methods[ $key ] : false;
$changed = wc_shipping_methods_have_changed( $key, $package );
// This is deprecated but here for BW compat. TODO: Remove in 4.0.0.
// This is deprecated but here for BW compat. Remove in 4.0.0.
$method_counts = WC()->session->get( 'shipping_method_counts' );
if ( ! empty( $method_counts[ $key ] ) ) {
@ -465,6 +469,12 @@ function wc_get_chosen_shipping_method_for_package( $key, $package ) {
WC()->session->set( 'chosen_shipping_methods', $chosen_methods );
WC()->session->set( 'shipping_method_counts', $method_counts );
/**
* Fires when a shipping method is chosen.
*
* @since 3.2.0
* @param string $chosen_method Chosen shipping method. e.g. flat_rate:1.
*/
do_action( 'woocommerce_shipping_method_chosen', $chosen_method );
}
return $chosen_method;
@ -536,6 +546,10 @@ function wc_get_default_shipping_method_for_package( $key, $package, $chosen_met
* @return bool
*/
function wc_shipping_methods_have_changed( $key, $package ) {
if ( ! is_callable( array( WC()->session, 'get' ) ) ) {
return false;
}
// Lookup previous methods from session.
$previous_shipping_methods = WC()->session->get( 'previous_shipping_methods' );
// Get new and old rates.