PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / inc / classes / class-merchant-ajax-callbacks.php

class-merchant-ajax-callbacks.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.2, at inc/classes/class-merchant-ajax-callbacks.php

45 lines 878 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Merchant_Ajax_Callbacks Class.
4 */
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 if ( ! class_exists( 'Merchant_Ajax_Callbacks' ) ) {
11
12 class Merchant_Ajax_Callbacks {
13
14 /**
15 * Constructor.
16 *
17 */
18 public function __construct() {
19
20 // Custom Add To Cart Button.
21 add_action( 'wp_ajax_merchant_custom_addtocart', array( $this, 'custom_addtocart_button' ) );
22 add_action( 'wp_ajax_nopriv_merchant_custom_addtocart', array( $this, 'custom_addtocart_button' ) );
23 }
24
25 /**
26 * Custom add to cart button callback.
27 *
28 */
29 public function custom_addtocart_button() {
30 check_ajax_referer( 'merchant-custom-addtocart-nonce', 'nonce' );
31
32 if ( ! isset( $_POST['product_id'] ) ) {
33 return;
34 }
35
36 WC()->cart->add_to_cart( absint( $_POST['product_id'] ) );
37
38 wp_die();
39 }
40 }
41
42 new Merchant_Ajax_Callbacks();
43
44 }
45