[Resolved] Copying the values from custom fields of CDX feed plugin
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing issues with custom fields not transferring correctly for variation products in a translating plugin and CDX feed plugin for Google Shopping, affecting pricing measures. Solution: If you're encountering similar issues, we recommend navigating to WPML -> Settings -> Custom Field Translation and setting those fields to 'Copy' as required. This process is detailed in our documentation, which you can find here: Translating Custom Fields. If you don't see those custom fields, try clicking 'Show System Fields' below the 'Custom Field Translation' heading. Then, search for 'Unit Price Measure' and 'GTIN' to ensure they are set to copy. Please remember to backup your database before making these changes.
This solution might be irrelevant if it's outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Our next available supporter will start replying to tickets in about 8.50 hours from now. Thank you for your understanding.
I discuss a problem I encountered with translating plugin and CDX feed plugin for Google Shopping. I explain how custom fields are not transferring for variation products, causing issues with pricing measures. I seek help on how to ensure these values are copied correctly for each variation.
If you don't see those custom fields, try clicking "Show System Fields" below the "Custom Field Translation" heading. Then, search for Unit Price Measure, Unit Price Measure, and GTIN to see if you find those fields.
Please remember to backup your database before you proceed.
Have you tried testing with a new product? Or did you modify the original product, save it, and navigate to the WPML translation editor to complete the translation?
If the issue persists, please try replicating it on the test installation I created. The link is in the private reply below.
Now I did modify the original product, saved it. (I didn't check the box Minor changes, no need to edit translations. So I had to resave all six translations). And it helped. Now there are values
But I have over 290 products. It is very tedious to resave them all especially with their translations it will take a very long time. Is there faster way to do it?
Unfortunately, no settings in WPML can help you achieve this. One option is to try updating the products in bulk mode by going to Products → All products, selecting at least a few products, and choosing Edit from the Bulk actions dropdown option. Choose the language before, if needed. This might resolve the issue.
You need to insert a code into your current theme's functions.php file, make necessary adjustments to it to work with the products, execute the code by refreshing the admin page, and then remove it.
Is this correct adjustment for this code to work with products:
// Add a function to the admin_init hook
add_action( 'admin_init', 'save_all_posts_on_refresh' );
// Define the function to save all posts on refresh
function save_all_posts_on_refresh() {
// Check if the current page is the posts page
global $pagenow;
if ( $pagenow == 'edit.php' ) {
// Get all the posts
$args = array(
'post_type' => array('product'),
'numberposts' => -1
);
$all_posts = get_posts( $args );
// Loop through all the posts and update them
foreach ( $all_posts as $single_post ) {
wp_update_post( $single_post );
}
}
}
I now I might sound annoying, but I really need to solve it, I hope you understand me, thanks