// Remove ALL private/system notes BEFORE Lightspeed syncs
add_filter('woocommerce_new_order_note_data', function($data) {

    // Kill WooPayments / fee / stock / system notes
    $blocked_keywords = [
        'Fee details',
        'Base fee',
        'Net payout',
        'WooPayments',
        'Stock levels reduced',
        'payment was successfully charged',
        'Payment via Card',
        'Stock hold'
    ];

    foreach ($blocked_keywords as $keyword) {
        if (stripos($data['comment_content'], $keyword) !== false) {
            return false; // STOP note from being created
        }
    }

    return $data;

}, 1);
// Add CLEAN delivery info note (what Lightspeed WILL import)
add_action('woocommerce_checkout_update_order_meta', function($order_id) {

    $date = get_post_meta($order_id, '_delivery_date', true);
    $time = get_post_meta($order_id, '_time_slot', true);

    if ($date || $time) {
        $note = "DELIVERY INFO:\n";

        if ($date) {
            $note .= "Date: " . $date . "\n";
        }

        if ($time) {
            $note .= "Time: " . $time;
        }

        $order = wc_get_order($order_id);
        $order->add_order_note($note, false); // FALSE = customer-visible note (important!)
    }

}, 5);{"version":"1.0","provider_name":"Garcia&#039;s Warehouse Inc.","provider_url":"https:\/\/garciaswarehouse.com\/es","author_name":"Garcias Warehouse","author_url":"https:\/\/garciaswarehouse.com\/es\/author\/garcias-warehouse\/","title":"Appliances - Garcia&#039;s Warehouse Inc.","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"6DlkO2MbFn\"><a href=\"https:\/\/garciaswarehouse.com\/es\/panorama-viewer\/appliances\/\">Electrodomesticos<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/garciaswarehouse.com\/es\/panorama-viewer\/appliances\/embed\/#?secret=6DlkO2MbFn\" width=\"600\" height=\"338\" title=\"&#8220;Appliances&#8221; &#8212; Garcia&#039;s Warehouse Inc.\" data-secret=\"6DlkO2MbFn\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script type=\"text\/javascript\">\n\/* <![CDATA[ *\/\n\/*! This file is auto-generated *\/\n!function(d,l){\"use strict\";l.querySelector&&d.addEventListener&&\"undefined\"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!\/[^a-zA-Z0-9]\/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),o=l.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),c=new RegExp(\"^https?:$\",\"i\"),i=0;i<o.length;i++)o[i].style.display=\"none\";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute(\"style\"),\"height\"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):\"link\"===t.message&&(r=new URL(s.getAttribute(\"src\")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener(\"message\",d.wp.receiveEmbedMessage,!1),l.addEventListener(\"DOMContentLoaded\",function(){for(var e,t,s=l.querySelectorAll(\"iframe.wp-embedded-content\"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute(\"data-secret\"))||(t=Math.random().toString(36).substring(2,12),e.src+=\"#?secret=\"+t,e.setAttribute(\"data-secret\",t)),e.contentWindow.postMessage({message:\"ready\",secret:t},\"*\")},!1)))}(window,document);\n\/\/# sourceURL=https:\/\/garciaswarehouse.com\/wp-includes\/js\/wp-embed.min.js\n\/* ]]> *\/\n<\/script>","thumbnail_url":"https:\/\/garciaswarehouse.com\/wp-content\/uploads\/2024\/10\/IMG_3754.jpeg","thumbnail_width":1000,"thumbnail_height":750}