File: classes/class-get-products.php
Lines: 2883-2916
What it does: Validates sale prices before including in feeds
File: includes/Integrations/WPML.php (Elite)
Lines: 262-291, 288, 291
What it does: Fixes WPML language switching for product feeds
Check:
- Verify sale end date is set:
$product->get_date_on_sale_to() - Check current timezone:
current_time( 'timestamp' ) - Verify validation logic is running (add debug log)
Debug Code:
// Add to sale price validation section
error_log( 'Sale Price Check - Product ID: ' . $product->get_id() );
error_log( 'Sale Price: ' . $sale_price );
error_log( 'Regular Price: ' . $regular_price );
error_log( 'Sale From: ' . ( $sale_from ? $sale_from->format( 'Y-m-d H:i:s' ) : 'none' ) );
error_log( 'Sale To: ' . ( $sale_to ? $sale_to->format( 'Y-m-d H:i:s' ) : 'none' ) );
error_log( 'Current Time: ' . date( 'Y-m-d H:i:s', $current_time ) );
error_log( 'Sale Valid: ' . ( $sale_valid ? 'yes' : 'no' ) );Check:
- WPML is active:
is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) - WPML support enabled:
get_option( 'adt_enable_wpml_support' ) === 'yes' - Language set in feed:
$feed->wpml - Products have translations
Debug Code:
// Add to set_language_before_processing()
error_log( 'WPML Language Switch - Feed ID: ' . $feed->id );
error_log( 'Selected Language: ' . $lang_code );
error_log( 'Current Language Before: ' . $sitepress->get_current_language() );
error_log( 'Current Language After: ' . $sitepress->get_current_language() );
// Add to set_product_query_language()
error_log( 'Query Args Language: ' . $lang_code );
error_log( 'Suppress Filters: ' . ( $args['suppress_filters'] ? 'true' : 'false' ) );Location: class-get-products.php lines 3033-3078
Issue: FlyCart discount plugin may override validated sale prices
Solution: Add validation after discount plugin calculation:
// After line 3077, add:
if ( isset( $product_data['sale_price'] ) && $product_data['sale_price'] > 0 ) {
$regular_price = $product_data['regular_price'] ?? 0;
if ( $product_data['sale_price'] >= $regular_price && $regular_price > 0 ) {
unset( $product_data['sale_price'] );
unset( $product_data['sale_price_forced'] );
// ... unset other sale price fields
}
}- Location:
class-get-products.php:2883 - Hook: None (direct validation)
- Filter Available:
adt_get_product_data(line 4245) - can modify product data
-
Hook:
woosea_before_get_products(action)- Location:
class-get-products.php:2095 - Handler:
WPML::set_language_before_processing()(priority 10)
- Location:
-
Hook:
adt_product_feed_get_products_query_args(filter)- Location:
class-get-products.php:2200 - Handler:
WPML::set_product_query_language()(priority 10)
- Location:
-
Hook:
adt_after_product_feed_generation(action)- Location:
Product_Feed.php:745 - Handler:
WPML::reset_language_after_processing()(priority 20)
- Location:
- Product with expired sale → No sale price in feed
- Product with future sale → No sale price in feed
- Product with valid sale → Sale price in feed
- Product with sale = regular → No sale price in feed
- Product with sale > regular → No sale price in feed
- Variable product with sale → Correct sale price
- Default language feed → Products in default language
- Non-default language feed → Products in selected language
- Feed with no language set → Uses default language
- Multiple feeds, different languages → Each in correct language
- Products without translation → Handled correctly
add_filter( 'adt_get_product_data', function( $product_data, $feed, $product ) {
// Your custom validation
if ( isset( $product_data['sale_price'] ) ) {
// Custom logic here
}
return $product_data;
}, 10, 3 );add_action( 'woosea_before_get_products', function( $feed ) {
// Your custom language setup
if ( $feed->custom_language ) {
// Switch to custom language
}
}, 5, 1 ); // Priority 5 to run before WPML (10)add_action( 'woosea_before_get_products', function( $feed ) {
error_log( 'Feed Generation Started - ID: ' . $feed->id );
error_log( 'Feed Language: ' . ( $feed->wpml ?? 'default' ) );
error_log( 'Feed Channel: ' . $feed->channel );
}, 1, 1 );- Check if discount plugin is active
- Verify sale dates in database
- Check WooCommerce sale status
- Review validation logs
- Verify WPML is active and configured
- Check
adt_enable_wpml_supportoption - Verify products have translations
- Check language selection in feed settings
- Review WPML debug logs
- Check Action Scheduler status
- Review batch sizes
- Check for memory issues
- Review query performance
| Component | File Path |
|---|---|
| Sale Price Validation | woo-product-feed-pro/classes/class-get-products.php:2883-2916 |
| WPML Language Switch | woo-product-feed-elite/includes/Integrations/WPML.php:135-147 |
| WPML Query Filter | woo-product-feed-elite/includes/Integrations/WPML.php:272-291 |
| Product Query Hook | woo-product-feed-pro/classes/class-get-products.php:2200 |
| Before Products Hook | woo-product-feed-pro/classes/class-get-products.php:2095 |
- v1.0 (2024): Initial implementation
- Sale price validation added
- WPML language switching fixed
- Query language filtering added