add_filter( 'wcml_custom_prices_fields', 'the_callback_function', 10, 2 );
- النوع
- filter
- الفئة
- ميزة تعدد العملات
- إصدار WooCommerce Multilingual
- 3.8
الوصف
- إضافة حقول أسعار مخصصة إضافية إلى المنتجات.
- تُعرض هذه الحقول في قسم تعيين الأسعار بعملات أخرى يدوياً عند تعديل/إنشاء المنتجات الأصلية.
- لإضافة تسميات حقول الأسعار المخصصة، راجع خطّاف wcml_custom_prices_fields_labels.
الوسطاء
يتم تمرير مَعلمتين إلى هذا المرشِّح:- $fields
- (مصفوفة) مصفوفة حقل السعر المخصص.
- $product_id
- (عدد صحيح) معرف منتج أصلي.
مثال على الاستخدام
استخدم كود المثال المقدم أدناه للحصول على النتائج المعروضة في لقطة الشاشة التالية.
مثال
/*
* Add this code to the functions.php file of your theme.
*/
add_filter( 'wcml_custom_prices_fields', 'add_custom_price_fields', 10, 2 );
function add_custom_price_fields( $fields, $product_id ) {
// Add a new custom price field
$fields[] = '_sign_up_fee';
return $fields;
}
add_filter( 'wcml_custom_prices_fields_labels', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $labels, $product_id ){
// Edit the label of a custom price field
$labels[ '_sign_up_fee' ] = __( 'Sign-up Fee', 'woocommerce-multilingual' );
return $labels;
}
خطاطيف ذات صلة
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_multi_currency_ajax_actions
