Created
June 7, 2018 20:31
-
-
Save MyronBatiuk/9f6abf415e0b7861a4d6a2028aa96007 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function ($) { | |
| var linkSubscribe = $ ('.product-form__cart-link'); | |
| var priceListItem = $ ('.product-subscription-block__price-list-item'); | |
| linkSubscribe.css ('display', 'none'); | |
| // There is a click with a pause for ReCharge | |
| setTimeout (function () { | |
| $ ('.rc_label__autodeliver').trigger ('click'); | |
| }, 1000); | |
| // Verification of changes input | |
| $ ('.product__price--form-text input').on ('change', function () { | |
| var inputValue = $ ('input[name=radio-group]:checked', '.product__price--form-text').val (); | |
| var btnAddToCart = $ ('.product-form__cart-submit'); | |
| var btnQuantity = $ ('.product-form__item--quantity'); | |
| (inputValue === 'Subscribe') ? ( | |
| linkSubscribe.css ('display', 'block'), | |
| btnAddToCart.hide (), | |
| btnQuantity.hide () | |
| ) : ( | |
| btnAddToCart.show (), | |
| linkSubscribe.css ('display', 'none'), | |
| btnQuantity.show () | |
| ); | |
| }); | |
| priceListItem.on ('click', function (e) { | |
| e.preventDefault (); | |
| var subscriptionBags = $ (this).find ('.subscription__bags').text (); | |
| var variant = $('.variant'); | |
| var descriptionListItem = $('.description-list-item'); | |
| descriptionListItem.hide().eq($(this).index()).show(); | |
| variant.find('option').removeAttr('selected'); | |
| variant.val($(this).attr('value')); | |
| variant.trigger ('click'); | |
| priceListItem.removeClass ('price-list-item__active'); | |
| $ (this).addClass ('price-list-item__active'); | |
| $ ('.product-subscription__amount--amount').text (subscriptionBags); | |
| }); | |
| $ ('.product-subscription-block__price-list-item:first-of-type').trigger ("click"); | |
| $ ('.product-subscription-block-how-often').hide (); | |
| $ ('#AddToCart-product-subscription-template').hide (); | |
| $ ('.frequency').hide (); | |
| // Step 2 subscription product | |
| $ ('.product-subscription__continue--link').on ('click', function (e) { | |
| e.preventDefault (); | |
| $ ('.product-subscription-block-left').hide (); | |
| $ ('.frequency').show (); | |
| $ ('.product-subscription-block-how-often').show (); | |
| $ ('#AddToCart-product-subscription-template').show (); | |
| $ (this).hide (); | |
| }); | |
| var howOftenListItem = $ ('.product-subscription-block__how-often-list-item'); | |
| howOftenListItem.on ('click', function (e) { | |
| e.preventDefault (); | |
| var frequency = $ (this).text (); | |
| var selectFrequency = $('.rc_select__frequency'); | |
| var frequencyListItem = $('.frequency-list-item'); | |
| frequencyListItem.hide().eq($(this).index()).show(); | |
| howOftenListItem.removeClass ('how-often-list__active'); | |
| $ (this).addClass ('how-often-list__active'); | |
| selectFrequency.find('option').removeAttr('selected'); | |
| selectFrequency.val($(this).attr('value')); | |
| selectFrequency.trigger ('click'); | |
| $ ('.product-subscription__frequency--amount').text (frequency); | |
| }); | |
| $ ('.product-subscription-block__how-often-list-item:first-of-type').trigger ("click"); | |
| // Cart page | |
| var listViewItem = $('.list-view-item__title').find('a'); | |
| listViewItem.each(function () { | |
| var text = $(this).text().trim(); | |
| var sliced = text.replace('Auto renew', ''); | |
| $(this).text(text.replace(text, sliced)); | |
| }); | |
| var subscriptionSummary = $('.description'); | |
| var subscriptionSummarySum = 0; | |
| var allOtherItems = $('.product-single__weight'); | |
| var allOtherItemsSum = 0; | |
| $.each(subscriptionSummary, function () { | |
| subscriptionSummarySum += parseFloat($(this).data('p')); | |
| }); | |
| $.each(allOtherItems, function () { | |
| allOtherItemsSum += parseFloat($(this).data('p')); | |
| }); | |
| $('.cart__product').text('$' + subscriptionSummarySum); | |
| $('.cart__total').text('$' + allOtherItemsSum); | |
| }) (jQuery); |
This file contains hidden or 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
| .main-collection { | |
| .collection-container { | |
| background: #faf4e9; | |
| padding-bottom: 21px; | |
| .collection__nav-list { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| margin: 30px 0 15px; | |
| flex-direction: row-reverse; | |
| @media screen and (min-width: 768px) { | |
| margin: 60px 0 30px; | |
| } | |
| .collection__nav-list-item { | |
| margin: 0 15px; | |
| @media screen and (min-width: 768px) { | |
| margin: 0 22px; | |
| } | |
| .collection__nav-list-item-link { | |
| color: #252b2d; | |
| font: 15px/20px 'GothamNarrow-Bold', sans-serif; | |
| text-transform: uppercase; | |
| letter-spacing: normal; | |
| transition: .4s; | |
| @media screen and (min-width: 768px) { | |
| font: 18px/24px 'GothamNarrow-Bold', sans-serif; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment