Orders complete WITHOUT “pick locker” selection
-
Hi all,
If it helps I can write this issue in Greek.
We have Stripe (credit card, apple pay, google pay) on our eshop with BOX NOW.
Some orders, proceed to payment WITHOUT the user selecting a locker.
How can we fix that?
We already added custom code:
add_action('woocommerce_checkout_process', 'require_boxnow_locker_selection');
function require_boxnow_locker_selection() {
// Only validate if BOX NOW shipping method is selected
$chosen_methods = WC()->session->get('chosen_shipping_methods');
if (in_array('boxnow_shipping_method', $chosen_methods)) { // Adjust to your exact method ID
$locker_id = $_POST['boxnow_locker_id'] ?? ''; // Field name from plugin; inspect form for exact
if (empty($locker_id)) {
wc_add_notice(__('Please select a BOX NOW locker location to proceed.', 'woocommerce'), 'error');
}
}
}function boxnow_fix_overlay() {
?>
<script type="text/javascript">
(function($){
window.addEventListener("message", function(event){
const data = event.data;
// Αν το iframe στείλει "closeIframe" ή αντικείμενο με boxnowClose
if(data === "closeIframe" || (typeof data === "object" && data?.boxnowClose !== undefined)){
// Αφαιρούμε overlay και iframe
$("#box_now_delivery_overlay").remove();
$("iframe[src^='https://widget-v5.boxnow.']").remove();
$(".boxnow-popup").remove();
}
}, false);
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'boxnow_fix_overlay', 100);add_action('woocommerce_email_before_order_table', 'add_boxnow_info_to_email', 10, 4);
function add_boxnow_info_to_email($order, $sent_to_admin, $plain_text, $email) {
if ($email->id !== 'customer_completed_order') {
return;
}
$parcel_ids = $order->get_meta('_boxnow_parcel_ids', true);
if (!empty($parcel_ids) && is_array($parcel_ids)) {
if ($plain_text) {
echo "\nBox Now:\n";
echo "<p>Παρακολούθηση δέματος: </p>";
foreach ($parcel_ids as $parcel_id) {
echo "https://boxnow.gr/?track=" . esc_html($parcel_id) . "\n";
}
} else {
echo '<h2>' . __('Box Now', 'woocommerce') . '</h2>';
echo '<p>Παρακολούθηση δέματος: </p>';
echo '<ul>';
foreach ($parcel_ids as $parcel_id) {
echo '<li><a href="https://boxnow.gr/?track=' . esc_html($parcel_id) . '" target="_blank">' . esc_html($parcel_id) . '</a></li>';
}
echo '</ul>';
}
}
}The page I need help with: [log in to see the link]
The topic ‘Orders complete WITHOUT “pick locker” selection’ is closed to new replies.