1jQuery( document ).ready( 2 function ($) { 3 4 $( document ).on( 5 'click', 6 '.wps-ob_ta-o-title', 7 function(e) { 8 if ($( e.target ).closest( '.add_offer_in_cart' ).length) { 9 return; 10 } 11 12 if (e.wps_ubo_title_click_handled) { 13 return; 14 } 15 e.wps_ubo_title_click_handled = true; 16 17 var bumpButton = $( this ).find( '.add_offer_in_cart' ).first(); 18 if ( ! bumpButton.length ) { 19 bumpButton = $( this ).closest( '.wps_upsell_offer_main_wrapper' ).find( '.add_offer_in_cart' ).first(); 20 } 21 22 if (bumpButton.length) { 23 bumpButton.trigger( 'click' ); 24 } else { 25 console.log( 'Element with class .add_offer_in_cart not found.' ); 26 } 27 } 28 ); 29 30 $( document ).on( 31 'click', 32 '.wps_product_discount', 33 function () { 34 35 jQuery( document ).trigger( 'wc_fragment_refresh' ); 36 // Get the value attribute from the div 37 var parent_product_id = jQuery( this ).closest( '.wps_main_class_order' ).find( '.wps_offered_product_id' ).val(); 38 39 // Get the quanity of the cart offer. 40 var wps_cart_offer_quantity = document.querySelector( '#wps_cart_offer_quantity' ); 41 var wps_cart_offer_quantity_value = wps_cart_offer_quantity.value; 42 43 // Get the product id of the cart offer. 44 var wps_cart_offer_product_id = document.querySelector( '#wps_cart_offer_product_id_' + parent_product_id ); 45 var wps_cart_offer_product_id_value = wps_cart_offer_product_id.value; 46 47 // Get the select element by its ID 48 var child_variation_id_element = document.querySelector( "#wps-order-bump-child-id_" + parent_product_id ); 49 50 if (null != child_variation_id_element) { 51 // Get the currently selected value 52 var child_variation_id = child_variation_id_element.value; 53 } else { 54 var child_variation_id = ''; 55 } 56 57 jQuery.ajax( 58 { 59 type: 'post', 60 dataType: 'json', 61 url: wps_ubo_lite_public_cart.ajaxurl, 62 data: { 63 nonce: wps_ubo_lite_public_cart.auth_nonce, 64 action: 'add_cart_discount_offer_in_cart', 65 parent_product_id: parent_product_id, 66 child_product_id: child_variation_id, 67 wps_cart_offer_quantity_value: wps_cart_offer_quantity_value, 68 wps_cart_offer_product_id_value: wps_cart_offer_product_id_value 69 }, 70 success: function (msg) { 71 $( document.body ).trigger( 'added_to_cart', {} ); 72 $( document.body ).trigger( 'update_checkout' ); 73 if (msg.message == 'remove') { 74 // Below code is to hide the offer section on adding to cart. 75 } 76 } 77 } 78 ); 79 80 } 81 ); 82 } 83);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.