Hi everyone,
I’m having trouble translating the color variations for my WooCommerce products. I’ve tried using the WP All Import plugin and the following code \[soflyy\_map\_kleur({color})\], but it doesn’t seem to be working.
Placed the below code in WP All Import Function Editor:
<?php
function soflyy_map_kleur($color)
{
// Define your mappings.
$map_values = array(
‘Gold’ => ‘Goud’,
‘Orange’ => ‘Oranje’,
‘Red’ => ‘Rood’,
‘Purple’ => ‘Paars’,
‘Blue’ => ‘Blauw’,
‘Grey’ => ‘Grijs’,
‘Green’ => ‘Groen’
);
// Separate the kleur by comma and convert to array.
$kleur = explode(“,”, $color);
// Declare a new array for our mapped kleur.
$mapped_kleur = array();
// Process each color.
foreach ($kleur as $color) {
// Check if we have a mapping for this color.
if (array_key_exists(trim($color), $map_values)) {
// If we do, use that value.
$mapped_kleur[] = $map_values[trim($color)];
} else {
// If we don’t have a value mapping you
// can perform some other action.
$mapped_kleur[] = $color;
}
}
// Return the mapped values as a comma-separated string.
return implode(“, “, $mapped_kleur);
}
?>
I’ve also enabled Taxonomy and auto-create terms, but still no luck.
Can anyone help me figure out what I’m doing wrong? Any suggestions or advice would be greatly appreciated.
Thanks in advance!
[ad_2]