- Megjött a jubileumi Pixel széria
- Google Pixel topik
- Itthon is elérhető a OnePlus 11 és a Buds Pro 2
- iPhone topik
- Samsung Galaxy S25 Edge - a tegnap határán
- Xiaomi 15 - kicsi telefon nagy energiával
- Motorola Edge 40 - jó bőr
- Android alkalmazások - szoftver kibeszélő topik
- Redmi Note 13 Pro 5G - nem százas, kétszázas!
- Apple Watch Ultra - első nekifutás
-
Mobilarena
WordPress tartalom kezelő rendszer (CMS) topik
Új hozzászólás Aktív témák
-
adatfalo
senior tag
válasz
kuyarashi #8982 üzenetére
Szia!
Vagy pluginnal, pl: Product Input Fields for WooCommerce és társai.
Vagy kóddal, ez egy példa, functions.php-ba kell betenni és személyre szabni:// Egyedi mezők hozzáadása a termék oldalra
add_action('woocommerce_before_add_to_cart_button', 'custom_product_fields', 10);
function custom_product_fields() {
echo '<div class="custom-fields">';
echo '<input type="text" name="custom_field_1" placeholder="Custom Field 1">';
echo '<input type="text" name="custom_field_2" placeholder="Custom Field 2">';
echo '</div>';
}
// Az egyedi mezők értékeinek mentése
add_filter('woocommerce_add_cart_item_data', 'save_custom_fields', 10, 2);
function save_custom_fields($cart_item_data, $product_id) {
if(isset($_POST['custom_field_1'])) {
$cart_item_data['custom_field_1'] = sanitize_text_field($_POST['custom_field_1']);
}
if(isset($_POST['custom_field_2'])) {
$cart_item_data['custom_field_2'] = sanitize_text_field($_POST['custom_field_2']);
}
return $cart_item_data;
}
// Az egyedi mezők megjelenítése a kosárban és a pénztárnál
add_filter('woocommerce_get_item_data', 'display_custom_fields', 10, 2);
function display_custom_fields($item_data, $cart_item) {
if(array_key_exists('custom_field_1', $cart_item)) {
$item_data[] = array(
'name' => 'Custom Field 1',
'value' => $cart_item['custom_field_1']
);
}
if(array_key_exists('custom_field_2', $cart_item)) {
$item_data[] = array(
'name' => 'Custom Field 2',
'value' => $cart_item['custom_field_2']
);
}
return $item_data;
}
// Az egyedi mezők hozzáadása az e-mail értesítésekhez
add_action('woocommerce_checkout_create_order_line_item', 'custom_fields_in_order_emails', 10, 4);
function custom_fields_in_order_emails($item, $cart_item_key, $values, $order) {
if(array_key_exists('custom_field_1', $values)) {
$item->add_meta_data('Custom Field 1', $values['custom_field_1']);
}
if(array_key_exists('custom_field_2', $values)) {
$item->add_meta_data('Custom Field 2', $values['custom_field_2']);
}
}
Új hozzászólás Aktív témák
- Óra topik
- Forza sorozat (Horizon/Motorsport)
- Kerékpárosok, bringások ide!
- One otthoni szolgáltatások (TV, internet, telefon)
- Renault, Dacia topik
- Gumi és felni topik
- Megjött a jubileumi Pixel széria
- Google Pixel topik
- India betiltja a pénzalapú online játékokat
- Építő/felújító topik
- További aktív témák...
- Iphone 14 Pro Max 128GB // Akku 100% // Számla + Garancia //
- ÁRGARANCIA!Épített KomPhone Ryzen 5 7500F 32/64GB DDR5 RTX 5060 8GB GAMER PC termékbeszámítással
- Honor Magic6 Pro 512GB, Kártyafüggetlen, 1 Év Garanciával
- Microsoft Surface Laptop 5 13,5" i7-1265U 16GB 256GB magyarbill 1 év garancia
- GYÖNYÖRŰ iPhone 12 Pro Max 128GB Blue -1 ÉV GARANCIA - Kártyafüggetlen, MS2107, 100% Akkumulátor
Állásajánlatok
Cég: FOTC
Város: Budapest