PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.8
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.8
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / integrations / woocommerce / includes / ajax-functions.php

ajax-functions.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.8, at integrations/woocommerce/includes/ajax-functions.php

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Ajax Functions
4 *
5 * @package GamiPress\WooCommerce\Ajax_Functions
6 * @since 1.1.3
7 */
8
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 // Return product variations dropdown for requirements UI
13 function gamipress_wc_ajax_get_product_variations() {
14
15 $product_id = $_POST['post_id'];
16 $site_id = $_POST['site_id'];
17 $selected = $_POST['selected'];
18
19 if( gamipress_is_network_wide_active() && $site_id !== get_current_blog_id() ) {
20 switch_to_blog( $site_id );
21 $product = wc_get_product( $product_id );
22 restore_current_blog();
23 } else {
24 $product = wc_get_product( $product_id );
25 }
26
27 // Bail if product doesn't exists
28 if( ! $product ) {
29 die();
30 }
31
32 $output = gamipress_wc_get_product_variations_dropdown( $product_id, $selected, $site_id );
33
34 // Bail if product has no variations
35 if( empty( $output ) ) {
36 echo '<span style="color: #a00;">This product has no variations</span>';
37 die();
38 }
39
40 echo $output;
41 die();
42
43 }
44 add_action( 'wp_ajax_gamipress_wc_get_product_variations', 'gamipress_wc_ajax_get_product_variations' );