How can I allow another script to run on the Home page apart from the standard script?
Hook
wcap_after_atc_scripts_loaded
Usage:
add_action( 'wcap_after_atc_scripts_loaded', 'wcap_load_custom_atc_script', PHP_INT_MAX, 3 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ add_action( 'wcap_after_atc_scripts_loaded', 'wcap_load_custom_atc_script', PHP_INT_MAX, 3 ); function wcap_load_custom_atc_script( $wcap_atc_modal, $wcap_populate_email_address, $atc_coupon_code ) { if ( is_front_page() ) { wp_dequeue_script( 'wc-add-to-cart-variation' ); wp_deregister_script( 'wc-add-to-cart-variation' ); wp_dequeue_script( 'wc-add-to-cart' ); wp_deregister_script( 'wc-add-to-cart' ); wp_register_script( 'wc-add-to-cart-variation' , WCAP_PLUGIN_URL . '/assets/js/frontend/wcap_atc_modal_single_product.js', array( 'jquery', 'wp-util' ), '', true ); wp_enqueue_script( 'wc-add-to-cart-variation' ); wp_localize_script( 'wc-add-to-cart-variation', 'wcap_atc_modal_param_variation', array( 'wcap_atc_modal_data' => $wcap_atc_modal, 'wcap_atc_head' => __( get_option('wcap_heading_section_text_email'), 'woocommerce-ac' ), 'wcap_atc_text' => __( get_option('wcap_text_section_text'), 'woocommerce-ac' ), 'wcap_atc_email_place' => __( get_option('wcap_email_placeholder_section_input_text'), 'woocommerce-ac' ), 'wcap_atc_button' => __( get_option('wcap_button_section_input_text'), 'woocommerce-ac' ), 'wcap_atc_button_bg_color' => get_option('wcap_button_color_picker'), 'wcap_atc_button_text_color'=> get_option('wcap_button_text_color_picker'), 'wcap_atc_popup_text_color' => get_option('wcap_popup_text_color_picker'), 'wcap_atc_popup_heading_color' => get_option('wcap_popup_heading_color_picker'), 'wcap_atc_mandatory_email' => get_option( 'wcap_atc_mandatory_email' ), 'wcap_atc_non_mandatory_input_text' => __( get_option('wcap_non_mandatory_text'), 'woocommerce-ac' ), 'wcap_populate_email' => $wcap_populate_email_address, 'wcap_ajax_url' => WCAP_ADMIN_URL, 'wcap_mandatory_text' => __('Email address is mandatory for adding product to the cart.', 'woocommerce-ac'), 'wcap_mandatory_email_text' => __(' Please enter a valid email address.', 'woocommerce-ac'), 'wcap_atc_coupon_applied_msg' => __( "Thank you. Coupon $atc_coupon_code will be auto-applied to your cart.", 'woocommerce-ac' ), ) ); } }
How can I change the message displayed for coupons which are automatically applied to the cart for ATC templates once the user enters their email address?
Hook
wcap_atc_coupon_applied_msg
Usage:
add_filter( 'wcap_atc_coupon_applied_msg', 'change_coupon_applied_msg', 10, 2 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ function change_coupon_applied_msg( $msg, $template_id ) { if ( 5 === (int) $template_id ) { // Add custom message only for a particular ATC template. $msg = __( 'Thanks for sharing your email address. Check your email for a special discount code.', 'woocommerce-ac' ); } return $msg; } add_filter( 'wcap_atc_coupon_applied_msg', 'change_coupon_applied_msg', 10, 2 );
How can I change the time duration for which the message to indicate a coupon has been applied to the cart is displayed in the ATC popup before fading away?
Hook
wcap_atc_coupon_applied_msg_fadeout_timer
Usage:
add_filter( 'wcap_atc_coupon_applied_msg_fadeout_timer', 'change_timer', 10, 2 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ function change_timer( $time, $template_id ) { if ( 5 === (int) $template_id ) { // Change the duration for only a given template ID. Skip the condition if it is to be applied for all the templates. $time = 5000; // milliseconds. } return $time; } add_filter( 'wcap_atc_coupon_applied_msg_fadeout_timer', 'change_timer', 10, 2 );
How can I add custom fields to the Add to Cart popup before email address field?
Hook
wcap_atc_before_form_fields
Usage:
add_action( 'wcap_atc_before_form_fields', 'add_first_name', 10 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ function add_first_name(){ echo '' } add_action( 'wcap_atc_before_form_fields', 'add_first_name', 10 );
How can I add custom fields to the ATC popup after the email address field?
Hook
wcap_atc_after_email_field
Usage:
add_action( 'wcap_atc_after_email_field', 'add_last_name', 10 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ function add_last_name(){ echo '' } add_action( 'wcap_atc_after_email_field', 'add_last_name', 10 );
How can I display the Add to Cart popup on custom taxonomy pages or any specific page of your choice?
Hook
wcap_enable_custom_conditions_popup_modal
Usage:
add_filter('wcap_enable_custom_conditions_popup_modal', 'wcap_enable_custom_conditions_popup_modal_callback', 10, 1);
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ function wcap_enable_custom_conditions_popup_modal_callback($value){ if( is_tax() ){ return true; } else { return false; } } add_filter('wcap_enable_custom_conditions_popup_modal', 'wcap_enable_custom_conditions_popup_modal_callback', 10, 1);
How can I add Custom validation for email field in Add to Cart popup or in Exit Intent popup?
Hook
wcap_extra_email_validation
Usage:
add_filter( 'wcap_extra_email_validation', 'wcap_check_email_validity', 10, 2 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ add_filter( 'wcap_extra_email_validation', 'wcap_check_email_validity', 10, 2 ); function wcap_check_email_validity ( $response, $email ) { if ( is_valid_email( $email ) ) { // Custom logic for successful validation of $email $response['status'] = 'success'; } else { //logic for invalid error message $response['status'] = 'error'; $response['msg'] = 'Custom error message for invalid email id'; } return $response; }
How can I add hook to show/hide the Exit Intent or Add to Cart popup?
Hook
wcap_return_popup_count
Usage:
add_filter( 'wcap_return_popup_count', 'wcap_return_count', 10, 2 );
Example:
/** * Add this code snippet in the "functions.php" file of your currently active theme. */ function wcap_return_count( $count, $type ) { if ( 'exit_intent' === $type ) { // Popup Type = Exit Intent. if ( is_user_logged_in() ) { // User is logged in. return 0; // Return 0 to not display the popup. } } return $count; } add_filter( 'wcap_return_popup_count', 'wcap_return_count', 10, 2 );