Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Last active January 23, 2024 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webtoffee-git/58871f861469f3518bf689a39fe91c4d to your computer and use it in GitHub Desktop.
Save webtoffee-git/58871f861469f3518bf689a39fe91c4d to your computer and use it in GitHub Desktop.
Generate product description for non english products - By WebToffee ( Product Import Export plugin )
<?php //Do not copy this line of code
function alter_product_description_content($messages, $data) {
// Check the language you want to generate the description in
$target_language = 'Spanish'; // Change this to the desired language
foreach ($messages as &$message) {
if ($message['role'] === 'user') {
$message['content'] = "Write a product description in $target_language with $tone tone, based on the following features: '{$data['product_description']}'.";
}
}
return $messages;
}
add_filter('wt_chatgpt_product_description_request', 'alter_product_description_content', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment