Navigation überspringen
Sun Mon Tue Wed Thu Fri Sat
- 6:00 – 12:00 8:00 – 12:00 6:00 – 12:00 8:00 – 12:00 6:00 – 12:00 -
- 13:00 – 15:00 13:00 – 17:00 13:00 – 15:00 13:00 – 17:00 13:00 – 15:00 -

Unterstützt die Zeitzone: America/Lima (GMT-05:00)

Dieses Thema enthält 0 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von Eslam Badr Vor 11 Monaten.

Assistiert von: Nicolas V..

Verfasser Beiträge
Juni 28, 2024 unter 5:22 pm #15853552

Eslam Badr

Background of the issue:
I am currently using the Product Feed Pro plugin along with WooCommerce and WooCommerce Multilingual & Multicurrency. I have added a custom field to my products to store a converted price in USD. The custom field "_converted_price" is visible and functioning correctly within the WooCommerce product edit screen. I added the following code to my theme's functions.php to create and save the custom field "_converted_price":

add_action('woocommerce_product_options_general_product_data', 'add_converted_price_custom_field');
add_action('woocommerce_process_product_meta', 'save_converted_price_custom_field');

function add_converted_price_custom_field() {
woocommerce_wp_text_input(
array(
'id' => '_converted_price',
'label' => __('Converted Price (USD)', 'woocommerce'),
'desc_tip' => 'true',
'description' => __('Enter the converted price in USD.', 'woocommerce'),
'type' => 'number',
'custom_attributes' => array(
'step' => 'any',
'min' => '0'
)
)
);
}

function save_converted_price_custom_field($post_id) {
$converted_price = isset($_POST['_converted_price']) ? sanitize_text_field($_POST['_converted_price']) : '';
update_post_meta($post_id, '_converted_price', $converted_price);
error_log("Saved converted price: $converted_price for product ID: $post_id");
}

add_filter('wcml_get_currency_converted_price', 'my_convert_price_to_USD', 10, 3);

function my_convert_price_to_USD($converted_price, $price, $target_currency) {
if ($target_currency === 'USD') {
return $converted_price;
} else {
$exchange_rates = get_option('wcml_exchange_rates');
$qatar_riyal_exchange_rate = isset($exchange_rates['QAR']['rate']) ? $exchange_rates['QAR']['rate'] : 1;
$converted_price_to_usd = $price / $qatar_riyal_exchange_rate;

global $post;
if (is_object($post)) {
update_post_meta($post->ID, '_converted_price', $converted_price_to_usd);
error_log("Converted price to USD: $converted_price_to_usd for product ID: {$post->ID}");
} elseif (is_object($product)) {
update_post_meta($product->get_id(), '_converted_price', $converted_price_to_usd);
error_log("Converted price to USD: $converted_price_to_usd for product ID: {$product->get_id()}");
}

return $converted_price_to_usd;
}
}

The custom field "_converted_price" appears correctly on the WooCommerce product edit screen, and its values are saved without issues.

my web is : versteckter Link

Symptoms:
I am unable to select or map the custom field "_converted_price" within the Product Feed Pro plugin to include it in my Google Merchant Center feed.

Questions:
How can I ensure that the custom field "_converted_price" is recognized and available for selection in the Product Feed Pro plugin?
Are there any additional steps or configurations required to include this custom field in my product feed for Google Merchant Center?

Das Thema '[Geschlossen] Custom Field' ist für neue Antworten geschlossen.