feat: cleanup and improvements for checkout fields
- Removed all debug logging (backend and frontend) - Added filter hook 'woonoow_standard_checkout_field_keys' for extensibility - Added form-row-wide class support to admin OrderForm - Tax is automatically handled by WC's calculate_totals()
This commit is contained in:
@@ -414,11 +414,6 @@ class CheckoutController {
|
||||
}
|
||||
|
||||
// Shipping (best‑effort estimate)
|
||||
// DEBUG: Log shipping data for troubleshooting
|
||||
error_log('[WooNooW Shipping Debug] shipping_method: ' . ($payload['shipping_method'] ?? 'null'));
|
||||
error_log('[WooNooW Shipping Debug] shipping_cost: ' . ($payload['shipping_cost'] ?? 'null'));
|
||||
error_log('[WooNooW Shipping Debug] shipping_title: ' . ($payload['shipping_title'] ?? 'null'));
|
||||
|
||||
if (!empty($payload['shipping_method'])) {
|
||||
$rate = $this->find_shipping_rate_for_order($order, $payload['shipping_method']);
|
||||
if ($rate instanceof WC_Shipping_Rate) {
|
||||
@@ -431,7 +426,6 @@ class CheckoutController {
|
||||
'taxes' => $rate->get_taxes(),
|
||||
]);
|
||||
$order->add_item($item);
|
||||
error_log('[WooNooW Shipping Debug] Added shipping via WC rate lookup: ' . $rate->get_cost());
|
||||
} elseif (!empty($payload['shipping_cost']) && $payload['shipping_cost'] > 0) {
|
||||
// Fallback: use shipping_cost directly from frontend
|
||||
// This handles API-based shipping like Rajaongkir where WC zones don't apply
|
||||
@@ -449,9 +443,6 @@ class CheckoutController {
|
||||
'total' => floatval($payload['shipping_cost']),
|
||||
]);
|
||||
$order->add_item($item);
|
||||
error_log('[WooNooW Shipping Debug] Added shipping via frontend fallback: ' . $payload['shipping_cost']);
|
||||
} else {
|
||||
error_log('[WooNooW Shipping Debug] NO shipping added - rate lookup failed and no valid shipping_cost');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,9 +562,10 @@ class CheckoutController {
|
||||
|
||||
/**
|
||||
* Get list of standard WooCommerce field keys
|
||||
* Plugins can extend this list via the 'woonoow_standard_checkout_field_keys' filter
|
||||
*/
|
||||
private function get_standard_field_keys(): array {
|
||||
return [
|
||||
$keys = [
|
||||
'billing_first_name',
|
||||
'billing_last_name',
|
||||
'billing_company',
|
||||
@@ -596,6 +588,14 @@ class CheckoutController {
|
||||
'shipping_postcode',
|
||||
'order_comments',
|
||||
];
|
||||
|
||||
/**
|
||||
* Filter the list of standard checkout field keys.
|
||||
* Plugins can add their own field keys to be recognized as "standard" (not custom).
|
||||
*
|
||||
* @param array $keys List of standard field keys
|
||||
*/
|
||||
return apply_filters('woonoow_standard_checkout_field_keys', $keys);
|
||||
}
|
||||
|
||||
/** ----------------- Helpers ----------------- **/
|
||||
|
||||
Reference in New Issue
Block a user