- Status
- Offen
- Gemeldet für
- WPML Multilingual & Multicurrency for WooCommerce 5.3.2
- Themen-Tags
- Bug
Übersicht über das Problem
Das Widget WooCommerce Status Dashboard zeigt möglicherweise eine falsche Anzahl für Produkte mit geringem Lagerbestand an. Dieses Problem tritt auf, wenn Produkte übersetzt werden, da das Widget Übersetzungen eines Produkts als separate Elemente zählt.
Problemumgehung
Bitte stellen Sie sicher, dass Sie über ein vollständiges Backup Ihrer Website verfügen, bevor Sie fortfahren.
- Öffnen Sie die Datei functions.php Ihres Themes.
- Fügen Sie den folgenden Code hinzu:
add_filter( 'woocommerce_status_widget_low_in_stock_count_pre_query', 'filter_counts' ); function filter_counts( $var ){ global $wpdb; $stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) ); $nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) ); $lowinstock_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( product_id ) FROM {$wpdb->wc_product_meta_lookup} AS lookup INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID INNER JOIN {$wpdb->prefix}icl_translations as translations ON posts.ID=translations.element_id WHERE stock_quantity <= %d AND stock_quantity > %d AND posts.post_status = 'publish' AND translations.source_language_code IS NULL", $stock, $nostock ) ); return $lowinstock_count; }