add_filter( 'wcml_update_custom_prices_values', 'the_callback_function', 10, 2 );
- ประเภท
- filter
- หมวดหมู่
- ฟีเจอร์หลายสกุลเงิน
- เวอร์ชันของ WooCommerce Multilingual
- 3.8
คำอธิบาย
กรองราคาที่กำหนดเองสำหรับสกุลเงินที่สองก่อนบันทึก
อาร์กิวเมนต์
มีพารามิเตอร์สองตัวที่ส่งไปยังฟิลเตอร์นี้:- $prices
- (array) อาร์เรย์ราคาที่กำหนดเองมีลักษณะดังต่อไปนี้:
array( '_regular_price' => $regular_price, '_sale_price' => $sale_price, '_wcml_schedule' => $schedule, '_sale_price_dates_from' => $date_from, '_sale_price_dates_to' => $date_to )- $currency
- (string) สกุลเงินที่สองที่มีการบันทึกราคาที่กำหนดเอง เช่น “USD”, “EUR” ฯลฯ
ตัวอย่างการใช้งาน
ตัวอย่าง
/*
* Add this code to the functions.php file of your theme.
*
* Assume:
* EUR = the default currency
* USD = the second currency
*/
add_filter( 'wcml_update_custom_prices_values', 'update_custom_prices_values', 10, 2 );
function update_custom_prices_values( $prices, $currency ){
if( 'USD' == $currency ){
// Set the fixed USD custom sale price for all products when saving
$prices[ '_sale_price' ] = 49;
}
return $prices;
}
ฮุกที่เกี่ยวข้อง
wcml_custom_prices_fields_labels, wcml_is_cache_enabled_for_switching_currency, wcml_geolocation_get_user_country, wcml_user_store_strategy, wcml_rounded_price, wcml_currencies_without_cents, wcml_product_custom_prices, wcml_custom_prices_strings, wcml_switch_currency, wcml_custom_prices_fields