PageSourceSearch

https://womencreate.com/wp-content/plugins/womencreate-custom-plug…ncreate-woo-customizations.js?ver=202104291

js womencreate.com collected 2026-10-01 14:51:40 UTC 5,263 bytes, 142 lines download raw bytes

1// Cookie Management
2function wcCreateCookie(name, value, days) {
3  var expires = "";
4  if (days) {
5    var date = new Date();
6    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
7    expires = "; expires=" + date.toUTCString();
8  }
9  document.cookie = name + "=" + value + expires + "; path=/";
10}
11
12function wcReadCookie(name) {
13  var nameEQ = name + "=";
14  var ca = document.cookie.split(';');
15  for (var i = 0; i < ca.length; i++) {
16    var c = ca[i];
17    while (c.charAt(0) == ' ') c = c.substring(1, c.length);
18    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
19  }
20  return null;
21}
22
23function wcEraseCookie(name) {
24  wcCreateCookie(name, "", -1);
25}
26
27jQuery(document).ready(function($) {
28  $('.membership-plan-action a').on('click', function() {
29    if ( !$(this).hasClass('photo-contest-cta-link') ) {
30      wcEraseCookie('wcSelectedContest');
31      wcEraseCookie('wcContestEntries');
32    }
33  });
34
35  // Add contest related cookies to be used at checkout
36  $('.photo-contest-cta-link').on('click', function() {
37    if ( $(this).attr('data-contest-id') ) {
38      wcCreateCookie('wcSelectedContest', $(this).attr('data-contest-id') );
39    }
40
41    if ( $(this).attr('data-contest-entries') ) {
42      wcCreateCookie('wcContestEntries', $(this).attr('data-contest-entries') );
43    }
44  });
45
46  // Delete the cookies on the gifting/switching template, always
47  if ( $('.is-gifting').length || $('.is-switching').length ) {
48    wcEraseCookie('wcSelectedContest');
49    wcEraseCookie('wcContestEntries');
50  }
51
52  // Using the cookies on the checkout page
53  var contest_id = wcReadCookie('wcSelectedContest');
54  var contest_entries = wcReadCookie('wcContestEntries');
55  if ( contest_id && contest_entries && $('#wc-woo-contest-id').length ) {
56    // If this isn't a contest, do not add contest data / delete the cookies
57    if ( $('.wc-lp-section-links').attr('data-not-contest-entry') ) {
58      wcEraseCookie('wcSelectedContest');
59      wcEraseCookie('wcContestEntries');
60    }
61    else {
62      $('#wc-woo-contest-id').val(contest_id);
63      $('#wc-woo-contest-entries').val(contest_entries);
64    }
65  }
66
67  // If this is a contest entry, make sure there is contest data
68  if ( $('.wc-lp-section-links').attr('data-contest-entry') ) {
69    if ( !$('#wc-woo-contest-id').val() || ! $('#wc-woo-contest-entries').val() ) {
70      var message = $('#no-checkout-contest-text').val();
71      if ( !$('.no-country-checkout-text').length ) {
72        $('#customer_details').prepend('<p class="no-country-checkout-text">' + message + '</p>');
73        $('#order_review, #customer_details .col-1, #customer_details .col-2, #order_review_heading').hide();
74      }
75
76      return;
77    }
78  }
79
80  if ( $('body').attr('data-variation-id') && $('body').attr('data-variation-name') ) {
81    $('.variations_form.cart td.value > select').val($('body').attr('data-variation-name'));
82    $('.variations_form.cart td.value > select').trigger('change');
83  }
84
85  if ( $('#billing_country').length ) {
86    $('#billing_country, #shipping_country').on('change', function() {
87      var val = $(this).val();
88      if ( val && val != 'US' && $('.wc-lp-section-links').attr('data-contest-entry') ) {
89        if ( $('#wc-woo-contest-id').val() || $('#billing_address_1').length || $('.wc-lp-section-links').attr('data-contest-entry') ) {
90          // User is not from the US. Should not be able to purchase contest entries or VIP / Plus memberships
91          var message = $('#no-checkout-country-text').val();
92          if ( $('#billing_address_1').length ) {
93            message = $('#no-checkout-country-membership-text').val();
94          }
95
96          if ( !$('.no-country-checkout-text').length ) {
97            $('#customer_details').prepend('<p class="no-country-checkout-text">' + message + '</p>');
98            $('#order_review, #customer_details .col-1, #customer_details .col-2, #order_review_heading').hide();
99          }
100        }
101      }
102      else {
103        if ( $('.no-country-checkout-text').length ) {
104          $('.no-country-checkout-text').remove();
105          $('#order_review, #customer_details .col-1, #customer_details .col-2').show();
106        }
107      }
108    });
109  }
110
111  function getQueryParams(qs) {
112      qs = qs.split("+").join(" ");
113      var params = {},
114          tokens,
115          re = /[?&]?([^=]+)=([^&]*)/g;
116
117      while (tokens = re.exec(qs)) {
118        params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
119      }
120
121      return params;
122  }
123
124  var $_GET = getQueryParams(document.location.search);
125  if ( $_GET['_wcgifting'] && $('.woocommerce_subscription_gifting_checkbox').length ) {
126    $('.woocommerce_subscription_gifting_checkbox').attr('checked', 'checked');
127
128    if ($('.woocommerce_subscriptions_gifting_recipient_email').size() > 0) {
129      $('.woocommerce_subscriptions_gifting_recipient_email').show();
130    }
131    $('#membership-options').on('change', function () {
132      $('.woocommerce_subscriptions_gifting_recipient_email').show();
133    });
134
135    $('form.variations_form.cart').on('submit', function( event ) {
136      if ( !$('input.input-text.recipient_email').val() ) {
137        event.preventDefault();
138        alert('To purchase a gift you must enter the gift recipient\'s email address.');
139      }
140    });
141  }
142});

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.