Last active
May 11, 2021 16:30
-
-
Save 10horizons/ce069f4519e0edbf26b840f0f5d64743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_upsell_popup_scripts_enqueue () { | |
if ( is_page( 13 ) ) { //CHANGE 13 TO THE ID OF YOUR PAGE! | |
wp_enqueue_script( 'thp-flickity-js', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/js/flickity.pkgd.min.js', array('jquery'), '', false ); | |
wp_enqueue_style( 'thp-flickity-style', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/css/flickity.min.css' ); | |
wp_enqueue_style( 'thp-flickity-style-fix', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/css/fix.min.css' ); | |
$ajax_enabled = get_option( 'woocommerce_enable_ajax_add_to_cart' ); | |
if ( 'yes' === $ajax_enabled ) { | |
wp_enqueue_script( 'thp-wuppro-js', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/js/wuppro-ajax.min.js', array('jquery','thp-flickity-js'), '', false ); | |
wp_localize_script( 'thp-wuppro-js', 'thp_wuppro_vars', array( | |
'ajaxurl' => admin_url( 'admin-ajax.php' ), | |
'added_to_cart' => __( 'Added to Cart!', 'woocommerce-upsell-popup-pro' ), | |
'added_to_cart_mult' => __( 'Successfully added to cart!', 'woocommerce-upsell-popup-pro' ), | |
'checkbox_warning' => __( 'Please select at least one item!', 'woocommerce-upsell-popup-pro' ), | |
'single_dropdown_warning' => __( 'Please choose one option!', 'woocommerce-upsell-popup-pro' ), | |
'mult_dropdown_warning' => __( 'You still have not chosen an option on at least one of your selected items!', 'woocommerce-upsell-popup-pro' ) | |
) | |
); | |
} | |
elseif ( 'yes' != $ajax_enabled ) { | |
wp_enqueue_script( 'thp-popup-mult-js', get_site_url().'/wp-content/plugins/woocommerce-upsell-popup-pro/js/wuppro-noajax.min.js', array('jquery','thp-flickity-js'), '', false ); | |
wp_localize_script( 'thp-popup-mult-js', 'thp_popup_mult_vars', array( | |
'checkbox_warning' => __( 'Please select at least one item!', 'woocommerce-upsell-popup-pro' ), | |
'single_dropdown_warning' => __( 'Please choose one option!', 'woocommerce-upsell-popup-pro' ), | |
'mult_dropdown_warning' => __( 'You still have not chosen an option on at least one of your selected items!', 'woocommerce-upsell-popup-pro' ) | |
) | |
); | |
} | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'my_upsell_popup_scripts_enqueue' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment