Enabled product bundles
This commit is contained in:
6
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php
Normal file → Executable file
6
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php
Normal file → Executable file
@@ -324,7 +324,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
||||
global $wpdb;
|
||||
|
||||
// Get from cache if available.
|
||||
$items = wp_cache_get( 'order-items-' . $order->get_id(), 'orders' );
|
||||
$items = 0 < $order->get_id() ? wp_cache_get( 'order-items-' . $order->get_id(), 'orders' ) : false;
|
||||
|
||||
if ( false === $items ) {
|
||||
$items = $wpdb->get_results(
|
||||
@@ -333,7 +333,9 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
||||
foreach ( $items as $item ) {
|
||||
wp_cache_set( 'item-' . $item->order_item_id, $item, 'order-items' );
|
||||
}
|
||||
wp_cache_set( 'order-items-' . $order->get_id(), $items, 'orders' );
|
||||
if ( 0 < $order->get_id() ) {
|
||||
wp_cache_set( 'order-items-' . $order->get_id(), $items, 'orders' );
|
||||
}
|
||||
}
|
||||
|
||||
$items = wp_list_filter( $items, array( 'order_item_type' => $type ) );
|
||||
|
||||
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-item-type-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-item-type-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-log-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-log-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-coupon-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-coupon-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-fee-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-fee-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-product-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-product-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-shipping-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-shipping-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-tax-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-tax-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-refund-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-refund-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-payment-token-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-payment-token-data-store.php
Normal file → Executable file
29
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php
Normal file → Executable file
29
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php
Normal file → Executable file
@@ -594,19 +594,24 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||
* @param WC_Product $product Product Object.
|
||||
*/
|
||||
protected function handle_updated_props( &$product ) {
|
||||
if ( in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) ) {
|
||||
if ( $product->get_sale_price( 'edit' ) >= $product->get_regular_price( 'edit' ) ) {
|
||||
update_post_meta( $product->get_id(), '_sale_price', '' );
|
||||
$product->set_sale_price( '' );
|
||||
$price_is_synced = $product->is_type( array( 'variable', 'grouped' ) );
|
||||
|
||||
if ( ! $price_is_synced ) {
|
||||
if ( in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) ) {
|
||||
if ( $product->get_sale_price( 'edit' ) >= $product->get_regular_price( 'edit' ) ) {
|
||||
update_post_meta( $product->get_id(), '_sale_price', '' );
|
||||
$product->set_sale_price( '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( in_array( 'date_on_sale_from', $this->updated_props, true ) || in_array( 'date_on_sale_to', $this->updated_props, true ) || in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) || in_array( 'product_type', $this->updated_props, true ) ) {
|
||||
if ( $product->is_on_sale( 'edit' ) ) {
|
||||
update_post_meta( $product->get_id(), '_price', $product->get_sale_price( 'edit' ) );
|
||||
$product->set_price( $product->get_sale_price( 'edit' ) );
|
||||
} else {
|
||||
update_post_meta( $product->get_id(), '_price', $product->get_regular_price( 'edit' ) );
|
||||
$product->set_price( $product->get_regular_price( 'edit' ) );
|
||||
|
||||
if ( in_array( 'date_on_sale_from', $this->updated_props, true ) || in_array( 'date_on_sale_to', $this->updated_props, true ) || in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) || in_array( 'product_type', $this->updated_props, true ) ) {
|
||||
if ( $product->is_on_sale( 'edit' ) ) {
|
||||
update_post_meta( $product->get_id(), '_price', $product->get_sale_price( 'edit' ) );
|
||||
$product->set_price( $product->get_sale_price( 'edit' ) );
|
||||
} else {
|
||||
update_post_meta( $product->get_id(), '_price', $product->get_regular_price( 'edit' ) );
|
||||
$product->set_price( $product->get_regular_price( 'edit' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
4
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-grouped-data-store-cpt.php
Normal file → Executable file
4
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-grouped-data-store-cpt.php
Normal file → Executable file
@@ -74,11 +74,13 @@ class WC_Product_Grouped_Data_Store_CPT extends WC_Product_Data_Store_CPT implem
|
||||
foreach ( $product->get_children( 'edit' ) as $child_id ) {
|
||||
$child = wc_get_product( $child_id );
|
||||
if ( $child ) {
|
||||
$child_prices[] = $child->get_price();
|
||||
$child_prices[] = $child->get_price( 'edit' );
|
||||
}
|
||||
}
|
||||
$child_prices = array_filter( $child_prices );
|
||||
delete_post_meta( $product->get_id(), '_price' );
|
||||
delete_post_meta( $product->get_id(), '_sale_price' );
|
||||
delete_post_meta( $product->get_id(), '_regular_price' );
|
||||
|
||||
if ( ! empty( $child_prices ) ) {
|
||||
add_post_meta( $product->get_id(), '_price', min( $child_prices ) );
|
||||
|
||||
2
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php
Normal file → Executable file
2
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php
Normal file → Executable file
@@ -515,6 +515,8 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple
|
||||
$prices = $children ? array_unique( $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_price' AND post_id IN ( " . implode( ',', array_map( 'absint', $children ) ) . ' )' ) ) : array(); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared
|
||||
|
||||
delete_post_meta( $product->get_id(), '_price' );
|
||||
delete_post_meta( $product->get_id(), '_sale_price' );
|
||||
delete_post_meta( $product->get_id(), '_regular_price' );
|
||||
|
||||
if ( $prices ) {
|
||||
sort( $prices );
|
||||
|
||||
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-shipping-zone-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-shipping-zone-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-webhook-data-store.php
Normal file → Executable file
0
backend/wordpress/wp-content/plugins/woocommerce/includes/data-stores/class-wc-webhook-data-store.php
Normal file → Executable file
Reference in New Issue
Block a user