'GET', 'callback' => function ($data) { $orders = wc_get_orders([ 'transaction_id' => sanitize_text_field($_GET['transaction_id']), ]); return [ 'exists' => count($orders) > 0, ]; } ]); } /** * add_checkout_script * Put the Checkout Snippet on WC template. * * @access public * @return void */ public function add_checkout_script() { $this->script(true); } public function add_cart_script() { $this->script(); } public function script($isCheckout = false) { ?> cart->get_cart(); $cart = []; foreach ($cartData as $key => $item) { $sanitizedItem = array_map('esc_html', $item); $cart['items'][] = [ 'product_id' => intval($sanitizedItem['product_id']), 'variant_id' => intval($sanitizedItem['variation_id']), 'quantity' => intval($sanitizedItem['quantity']), ]; } return json_encode($cart); } /** * woo_custom_add_to_cart_before * * Add to cart before. * * @access public * @return string */ public function woo_custom_add_to_cart_before( $cart_item_data ) { WC()->cart->empty_cart(); // Do nothing with the data and return return true; } } /** * Load Checkout */ function abmex_checkout_plugins_loaded() { new AbmexCheckout_WC(); } add_action('plugins_loaded', 'abmex_checkout_plugins_loaded');