403 forbidden error
-
hi there,
I get a 403 forbidden error (from the server triggering a Modsec rule) when trying to add this inside Fluent Snippets, but it applies ok using Code Snippets. Any idea why?
// Add delivery date field to the checkout
add_action("woocommerce_after_order_notes", "cwpai_add_delivery_date_field");
function cwpai_add_delivery_date_field($checkout)
{
$min_date = date('Y-m-d', strtotime('+0 days')); // 0 days from today
$max_date = date('Y-m-d', strtotime('+0 days')); // 0 days from today
echo '<div id="cwpai_delivery_date_field"><h2>' . __("Delivery Date") . "</h2>";
woocommerce_form_field(
"cwpai_delivery_date",
[
"type" => "date",
"class" => ["cwpai-field-class form-row-wide"],
"required" => true, // this field is mandatory
"custom_attributes" => [
'min' => $min_date,
'max' => $max_date
],
],
$checkout->get_value("cwpai_delivery_date")
);
echo "</div>";
}
// Save delivery date to the order meta
add_action(
"woocommerce_checkout_update_order_meta",
"cwpai_save_delivery_date_to_order_meta"
);
function cwpai_save_delivery_date_to_order_meta($order_id)
{
if (!empty($_POST["cwpai_delivery_date"])) {
update_post_meta(
$order_id,
"cwpai_delivery_date",
sanitize_text_field($_POST["cwpai_delivery_date"])
);
}
}
// Display delivery date in the custom column
add_action('woocommerce_admin_order_data_after_shipping_address', 'cwpai_my_orders_delivery_date_column');
function cwpai_my_orders_delivery_date_column($order)
{
$delivery_date = "<strong>Delivery Date:</strong><br>" . get_post_meta($order->get_id(), 'cwpai_delivery_date', true); // Get custom order meta
echo !empty($delivery_date) ? $delivery_date : 'N/A';
}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.