Skip to main content

Price Matching Campaigns

Overviewโ€‹

Applies campaign-specific price matching for tagged customers. Customers with specific tags receive special pricing on tagged products.

Eligibilityโ€‹

Customer must have one or more of these tags:

  • "eoy24-price-match" โ†’ End of Year 2024 campaign
  • "jan25-price-match" โ†’ January 2025 campaign
  • "satinpillar25-price-match" โ†’ Satin Pillar 2025 campaign
  • "marchpromo25-price-match" โ†’ March 2025 promo campaign
  • "whapril2025-price-match" โ†’ Warehouse Sale April 2025 campaign

How It Worksโ€‹

1. Tag Matchingโ€‹

Script checks which eligible tags the customer has.

For each eligible customer tag, searches product tags for matching prefix:

Customer TagProduct Tag PrefixCampaign Message
eoy24-price-matcheoy24-"End of Year Sale Price Match!"
jan25-price-matchpriceincjan25-"January Price Match!"
satinpillar25-price-matchsatinpillar25-"Satin Pillar Price Match!"
marchpromo25-price-matchmarchpromo25-"March Promo Price Match!"
whapril2025-price-matchwhapril2025-"Warehouse Sale Price Match!"

3. Price Extractionโ€‹

Extracts price from product tag format: {prefix}-{price}

Example: "jan25-45.99" โ†’ 4599 cents

4. Lowest Price Selectionโ€‹

If multiple price matches are found, the lowest price is selected.

5. Personalization Surchargeโ€‹

If variant title contains "Personalized" (but NOT "Not Personalized"), adds $6 to the matched price.

Note: This surcharge ONLY applies to price matches, not compare at price discounts.

6. Discount Applicationโ€‹

Applies the matched price with the corresponding campaign message.

Discount Message Formatโ€‹

"{Campaign Message} {X}% off!"

Example: "January Price Match! 30% off!"

Technical Implementationโ€‹

Configuration Hashโ€‹

eligible_tags = {
"eoy24-price-match" => {
prefix: "eoy24-",
message: "End of Year Sale Price Match!"
},
"jan25-price-match" => {
prefix: "priceincjan25-",
message: "January Price Match!"
},
"satinpillar25-price-match" => {
prefix: "satinpillar25-",
message: "Satin Pillar Price Match!"
},
"marchpromo25-price-match" => {
prefix: "marchpromo25-",
message: "March Promo Price Match!"
},
"whapril2025-price-match" => {
prefix: "whapril2025-",
message: "Warehouse Sale Price Match!"
}
}

Logic Flowโ€‹

def find_best_price_match(line_item, customer_tags, eligible_tags)
best_price = nil
best_message = nil

customer_tags.each do |tag|
next unless eligible_tags.key?(tag)

config = eligible_tags[tag]
line_item.variant.product.tags.each do |product_tag|
if product_tag.start_with?(config[:prefix])
price_str = product_tag.sub(config[:prefix], "")
price_cents = (Float(price_str) * 100).to_i rescue nil

if price_cents && (!best_price || price_cents < best_price)
best_price = price_cents
best_message = config[:message]
end
end
end
end

# Add personalization surcharge if applicable
if best_price && line_item.variant.title.include?("Personalized") &&
!line_item.variant.title.include?("Not Personalized")
best_price += 600 # Add $6
end

return best_price, best_message
end

Price Extraction Rulesโ€‹

  • Product tags must follow format: {prefix}-{price}
  • Invalid formats are skipped (rescue nil on Float conversion)
  • Prices are stored internally in cents

Adding New Campaignsโ€‹

To add a new price match campaign:

1. Update the Scriptโ€‹

"new-campaign-tag" => {
prefix: "newcampaign-",
message: "New Campaign Message!"
}

2. Tag Customersโ€‹

Tag eligible customers with "new-campaign-tag".

3. Tag Productsโ€‹

Tag products with "newcampaign-PRICE".

Example: "newcampaign-39.99" for a $39.99 price match.

Priorityโ€‹

Price matching has higher priority than compare at price discounts.

If a customer qualifies for both:

  1. Price match is applied โœ…
  2. Compare at price is skipped

Guest Handlingโ€‹

โŒ Guests cannot receive price matching discounts since they don't have customer tags.