/** * הוספת עריכת משקל לפריט הזמנה ישירות באזור המטא * Weight Edit for Order Items - Inline in Meta Area */ // הוספת שדה משקל לאזור המטא של הפריט add_action('woocommerce_before_order_item_object_save', 'add_weight_meta_to_order_item', 10, 2); function add_weight_meta_to_order_item($item, $data_store) { // בדיקה אם זה פריט עם מכירה במשקל if ($item->get_type() !== 'line_item') { return; } $product_id = $item->get_product_id(); $weight_based_selling = get_post_meta($product_id, '_weight_based_selling', true); if ($weight_based_selling !== 'yes') { return; } // קבלת המשקל הנוכחי או ברירת מחדל $current_weight = $item->get_meta('product_weight', true); if (empty($current_weight)) { $min_weight = get_post_meta($product_id, '_min_weight', true); $current_weight = $min_weight ?: 1; $item->update_meta_data('product_weight', $current_weight); } // שמירת המחיר המקורי אם עוד לא נשמר $original_price = $item->get_meta('_original_order_price', true); if (empty($original_price)) { $item->update_meta_data('_original_order_price', $item->get_total()); } } // הוספת JavaScript לעמוד עריכת הזמנה add_action('admin_footer', 'add_weight_edit_inline_script'); function add_weight_edit_inline_script() { global $pagenow, $post; if ($pagenow !== 'post.php' || !isset($post->post_type) || $post->post_type !== 'shop_order') { return; } ?>