add_action('woocommerce_checkout_create_order', function($order, $data) {
if (!isset($_REQUEST['wc_order_attribution_utm_source'])) {
wc_add_notice(__('Order creation failed: Safetech Security.', 'woocommerce'), 'error');
throw new Exception('Order creation halted.');
} }, 10, 2);
This works for me
Updates the issue is in the Paypal wooocommerce plugin, I had to edit the code and stop auto-update
if (!isset($_COOKIE['sbjs_first'])) {
throw new RuntimeException(
__('Order creation failed: Origin source is required.', 'woocommerce-paypal-payments')
);
}
woocommerce-paypal-payments\modules\ppcp-button\src\Endpoint\CreateOrderEndpoint.php …
at the beginning of this function
private function create_paypal_order( \WC_Order $wc_order = null, string $payment_method = '', array $data = array() ): Order {
// Check origin source from session
if (!isset($_COOKIE['sbjs_first'])) {
throw new RuntimeException(
__('Order creation failed: Origin source is required.', 'woocommerce-paypal-payments')
);
}
assert( $this->purchase_unit instanceof PurchaseUnit );