Skip to content

Instantly share code, notes, and snippets.

@bogdan
Last active July 10, 2017 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan/64d61d9deedf299057144b1fbbad66e5 to your computer and use it in GitHub Desktop.
Save bogdan/64d61d9deedf299057144b1fbbad66e5 to your computer and use it in GitHub Desktop.
diff --git a/app/liquid/templates/shared/_offers_claim.erb b/app/liquid/templates/shared/_offers_claim.erb
index b29e040521..03796ab6ff 100644
--- a/app/liquid/templates/shared/_offers_claim.erb
+++ b/app/liquid/templates/shared/_offers_claim.erb
@@ -6,7 +6,7 @@
{% endif %}
{% if friend_reward != blank %}
- {% assign friend_claim_page_hide_coupon_code = "hide_coupon_code" | localize: "Yes", "No", trait: "boolean", default: "No" %}
+ {% assign hide_coupon_code = "hide_coupon_code" | localize: "Yes", "No", trait: "boolean", default: "No" %}
{% endif %}
{% capture incentives_count %}
@@ -31,16 +31,6 @@
{% endfor %}
{% endcapture %}
-{% assign skip_email_gating_for_self_referral = false %}
-{% if is_self_referral and friend_incentive_self_referral == blank %}
- {% assign skip_email_gating_for_self_referral = true %}
-{% endif %}
-
-{% assign hide_coupon_code = false %}
-{% if friend_claim_page_hide_coupon_code %}
- {% assign hide_coupon_code = true %}
-{% endif %}
-
{% if friend_incentive_new_customer != blank and friend_incentive_existing_customer == blank %}
{% assign friend_claim_page_disclaimer = "friend_claim_page_new_customer_disclaimer" | localize: "Discount is valid for new customers only." %}
{% elsif friend_incentive_existing_customer != blank and friend_incentive_new_customer == blank %}
@@ -57,32 +47,21 @@
{% endif %}
{% endcapture %}
-{% assign ineligible = false %}
-{% if campaign_setup.rules.require_email_to_claim %}
- {% if friend_offer.active %}
- {% if friend_info.email == blank and friend_incentives_count != friend_incentive_expired and skip_email_gating_for_self_referral == false %}
- {% assign show_email_gating = true %}
- {% else %}
- {% assign show_email_gating = false %}
- {% endif %}
- {% else %}
- {% if friend_info.email == blank and friend_incentive_expired != blank %}
- {% assign show_email_gating = true %}
- {% else %}
- {% assign show_email_gating = false %}
- {% endif %}
- {% endif %}
-{% else %}
- {% assign show_email_gating = false %}
-{% endif %}
-{% if friend_offer.active %}
- {% if show_email_gating %}
- <!-- Email gating variables -->
- {% assign headline = "friend_claim_page_email_gating_headline" | localize: "You've got [[ friend_incentive.description ]] to shop!" %}
- {% assign description = "friend_claim_page_email_gating_description" | localize: "Thanks to a great friend, you have a [[ friend_incentive.description ]] discount to shop at [[ site_setup.name ]]. Enter your email to get it:" %}
- {% assign cta = "friend_claim_page_email_gating_cta" | localize: "Get my discount" %}
- <!-- End email gating variables -->
+ {% if friend_offer.show_signup %}
+ {% if friend_offer.active %}
+ <!-- Email gating variables -->
+ {% assign headline = "friend_claim_page_email_gating_headline" | localize: "You've got [[ friend_incentive.description ]] to shop!" %}
+ {% assign description = "friend_claim_page_email_gating_description" | localize: "Thanks to a great friend, you have a [[ friend_incentive.description ]] discount to shop at [[ site_setup.name ]]. Enter your email to get it:" %}
+ {% assign cta = "friend_claim_page_email_gating_cta" | localize: "Get my discount" %}
+ <!-- End email gating variables -->
+ {% else %}
+ <!-- Expired email gating variables -->
+ {% assign headline = "friend_claim_page_expired_email_gating_headline" | localize: "You've got [[ friend_incentive.description ]] to shop!" %}
+ {% assign description = "friend_claim_page_expired_email_gating_description" | localize: "Thanks to a great friend, you have a [[ friend_incentive.description ]] discount to shop at [[ site_setup.name ]]. Enter your email to get it:" %}
+ {% assign cta = "friend_claim_page_expired_email_gating_cta" | localize: "Get my discount" %}
+ <!-- End expired email gating variables -->
+ {% end %}
{% else %}
{% if friend_reward != blank %}
@@ -99,6 +78,12 @@
{% assign description = "friend_claim_page_self_referral_copy" | localize: "The Refer a Friend deal is valid for your friends and not intended to be used on your own purchase. Here's a [[ friend_reward.incentive.description ]] code as a thank you for referring your friends:" %}
{% assign cta = "friend_claim_page_self_referral_cta" | localize: "Shop now" %}
<!-- End eligible self referral variables -->
+ {% elsif friend_reward.incentive.criteria_config.allow_on_expired_offer %}
+ <!-- Expired reward variables -->
+ {% assign headline = "friend_claim_page_expired_reward_headline" | localize: "We're sorry" %}
+ {% assign description = "friend_claim_page_expired_reward_copy" | localize: "That offer is expired. Here's a [[ friend_reward.incentive.description ]] code for today's purchase:" %}
+ {% assign cta = "friend_claim_page_expired_reward_cta" | localize: "Shop Now" %}
+ <!-- End expired reward variables -->
{% else %}
{% if friend_incentive.amount > friend_reward.incentive.amount and friend_incentive.percentage == friend_reward.incentive.percentage %}
<!-- Not top reward variables -->
@@ -117,29 +102,31 @@
{% else %}
{% if is_self_referral %}
<!-- Ineligible self referral variables -->
- {% assign ineligible = true %}
{% assign headline = "friend_claim_page_ineligible_self_referral_title" | localize: "We're sorry" %}
{% assign description = "friend_claim_page_ineligible_self_referral_copy" | localize: "The Refer a Friend offer is valid for your friends and not intended to be used on your own purchase." %}
{% assign cta = "friend_claim_page_ineligible_self_referral_cta" | localize: "Shop now" %}
<!-- End ineligible self referral variables -->
+ {% elsif !friend_offer.active %}
+ <!-- Expired offer variables -->
+ {% assign headline = "friend_claim_page_expired_headline" | localize: "Your offer is expired." %}
+ {% assign description = "friend_claim_page_expired_description" | localize: "Ask your friend [[ advocate_info.email ]] to share with you again. Good luck!" %}
+ {% assign cta = "friend_claim_page_expired_cta" | localize: "Shop Now" %}
+ <!-- End expired offer variables -->
{% elsif friend_incentive_new_customer != blank and is_new_customer == false %}
<!-- Ineligible existing customer variables -->
- {% assign ineligible = true %}
{% assign headline = "friend_claim_page_not_new_customer_title" | localize: "We're sorry" %}
{% assign description = "friend_claim_page_not_new_customer_copy" | localize: "This offer is for first time customers only." %}
{% assign cta = "friend_claim_page_not_new_customer_cta" | localize: "Shop now" %}
<!-- End ineligible existing customer variables -->
{% elsif friend_incentive_existing_customer != blank and is_new_customer %}
<!-- Ineligible new customer variables -->
- {% assign ineligible = true %}
{% assign headline = "friend_claim_page_new_customer_title" | localize: "We're sorry" %}
{% assign description = "friend_claim_page_new_customer_copy" | localize: "This offer is for existing customers only." %}
{% assign cta = "friend_claim_page_new_customer_cta" | localize: "Shop now" %}
<!-- End ineligible new customer variables -->
{% else %}
<!-- Ineligible variables -->
- {% assign ineligible = true %}
{% assign headline = "friend_claim_page_no_reward_headline" | localize: "We're sorry" %}
{% assign description = "friend_claim_page_no_reward_description" | localize: "You are ineligible for a reward" %}
{% assign cta = "friend_claim_page_no_reward_cta" | localize: "Shop Now" %}
@@ -148,44 +135,6 @@
{% endif %}
{% endif %}
-<!-- Friend offer not active -->
-{% else %}
-
- {% if friend_incentive_expired != blank %}
- {% if show_email_gating %}
- <!-- Expired email gating variables -->
- {% assign headline = "friend_claim_page_expired_email_gating_headline" | localize: "You've got [[ friend_incentive.description ]] to shop!" %}
- {% assign description = "friend_claim_page_expired_email_gating_description" | localize: "Thanks to a great friend, you have a [[ friend_incentive.description ]] discount to shop at [[ site_setup.name ]]. Enter your email to get it:" %}
- {% assign cta = "friend_claim_page_expired_email_gating_cta" | localize: "Get my discount" %}
- <!-- End expired email gating variables -->
- {% else %}
-
- {% if friend_reward != blank %}
- <!-- Expired reward variables -->
- {% assign headline = "friend_claim_page_expired_reward_headline" | localize: "We're sorry" %}
- {% assign description = "friend_claim_page_expired_reward_copy" | localize: "That offer is expired. Here's a [[ friend_reward.incentive.description ]] code for today's purchase:" %}
- {% assign cta = "friend_claim_page_expired_reward_cta" | localize: "Shop Now" %}
- <!-- End expired reward variables -->
- {% else %}
- <!-- Ineligible expired reward variables -->
- {% assign ineligible = true %}
- {% assign headline = "friend_claim_page_expired_no_reward_headline" | localize: "We're sorry" %}
- {% assign description = "friend_claim_page_expired_no_reward_description" | localize: "You are ineligible for a reward" %}
- {% assign cta = "friend_claim_page_expired_no_reward_cta" | localize: "Shop Now" %}
- <!-- End ineligible expired reward variables -->
- {% endif %}
-
- {% endif %}
-
- {% else %}
- <!-- Expired offer variables -->
- {% assign headline = "friend_claim_page_expired_headline" | localize: "Your offer is expired." %}
- {% assign description = "friend_claim_page_expired_description" | localize: "Ask your friend [[ advocate_info.email ]] to share with you again. Good luck!" %}
- {% assign cta = "friend_claim_page_expired_cta" | localize: "Shop Now" %}
- <!-- End expired offer variables -->
- {% endif %}
-{% endif %}
-<!-- End Friend offer not active -->
<!-- Disclaimer block-->
@@ -206,7 +155,7 @@
<!-- Email gating block -->
{% capture email_gating %}
- {% if show_email_gating %}
+ {% if friend_offer.show_signup %}
<div class="signup-form">
<form class="js-gating" action="#" accept-charset="UTF-8">
<input type="text" class="textfield is-center js-gating-email ac-gating-email-input" name="person[email]" placeholder="Enter your email" value="" />
@@ -231,7 +180,7 @@
<!-- Reward block -->
{% capture reward_block %}
- {% if friend_reward != blank and ineligible == false and show_email_gating == false %}
+ {% if friend_reward != blank %}
<!-- Coupon code block -->
<div class="signup-form ac-promo-code">
{% if hide_coupon_code == false %}
@@ -248,7 +197,7 @@
{{ disclaimer }}
</div>
<!-- End coupon code block -->
- {% elsif friend_reward == blank and show_email_gating == false %}
+ {% elsif friend_offer.show_signup == false %}
<!-- No reward and skip email gating -->
<div class="signup-form">
<a class="button is-block is-large ac-proceed-link" href="{{ proceed_to_merchant_url }}">
diff --git a/app/models/incentive.rb b/app/models/incentive.rb
index 8f3e8c75f8..2ed97a3151 100644
--- a/app/models/incentive.rb
+++ b/app/models/incentive.rb
@@ -629,7 +629,7 @@ protected
return if new_record? || !campaign.test_mode?
changed = changes.slice(*NOT_CHANGEABLE_ATTRIBUTES).any? || criteria_changed? || marked_for_destruction?
- campaign.flush_data if changed && campaign.has_activities?
+ #campaign.flush_data if changed && campaign.has_activities?
end
def normalize_fields
diff --git a/app/models/visitor_offer.rb b/app/models/visitor_offer.rb
index 6c1f42b8cc..6605eb59eb 100644
--- a/app/models/visitor_offer.rb
+++ b/app/models/visitor_offer.rb
@@ -511,6 +511,7 @@ class VisitorOffer < BaseModel
value: share.friend_offer_interpolation.merge(
id: id,
ip: proc { IPAddress.to_liquid(ip_address, site) },
+ show_signup: proc { show_signup? },
),
inherit: true,
presetable: true,
@@ -560,6 +561,11 @@ class VisitorOffer < BaseModel
))
end
+ def show_signup?
+ !person && require_email_to_claim? &&
+ !!click_incentive #only to people still eligible for any reward
+ end
+
private
def push_to_reporting_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment