Skip to content

Commit 0c75938

Browse files
Merge pull request #16 from Nils-van-Kleef/master
econda Analytics files + Multibuy Offer Reminder extension added + Adding Price Changer Extension
2 parents 4f181b2 + 625faeb commit 0c75938

File tree

9 files changed

+175
-0
lines changed

9 files changed

+175
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Multibuy Offer Reminder
2+
3+
![Screenshot](https://github.com/optimizely/extension-library/blob/master/Extensions/Editor%20Extensions/Multibuy%20Offer%20Reminder/screenshot.png)
4+
5+
## Description
6+
7+
Displays an offer popup when the audience conditions are met (e.g. visitor added 3 products to the shopping cart). Audience will need to be created separately.
8+
9+
## Fields
10+
11+
* Message copy
12+
* CTA copy
13+
* CTA URL
14+
* Dismiss copy
15+
* Overlay background
16+
* Window background
17+
* Message color
18+
* CTA color
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"plugin_type": "widget",
3+
"name": "Multibuy Offer Reminder",
4+
"edit_page_url": "https://playground.optimizely.how/",
5+
"form_schema": [
6+
{
7+
"default_value": "Take me to the shop",
8+
"field_type": "text",
9+
"name": "text_cta",
10+
"label": "CTA copy",
11+
"options": null
12+
},
13+
{
14+
"default_value": "Thanks, but no thanks",
15+
"field_type": "text",
16+
"name": "text_dismiss",
17+
"label": "Dismiss copy",
18+
"options": null
19+
},
20+
{
21+
"default_value": "http://playground.optimizely.how/mens",
22+
"field_type": "text",
23+
"name": "cta_url",
24+
"label": "CTA URL",
25+
"options": null
26+
},
27+
{
28+
"default_value": "Add one more product to your cart and get 15% off at checkout!",
29+
"field_type": "text",
30+
"name": "msg_copy",
31+
"label": "Message copy",
32+
"options": null
33+
},
34+
{
35+
"default_value": "rgba(0, 0, 0, 0.75)",
36+
"field_type": "color",
37+
"name": "overlay_color",
38+
"label": "Overlay background",
39+
"options": {
40+
"mode": "rgba"
41+
}
42+
},
43+
{
44+
"default_value": "#ffffff",
45+
"field_type": "color",
46+
"name": "modal_color",
47+
"label": "Window background",
48+
"options": {
49+
"mode": "hex"
50+
}
51+
},
52+
{
53+
"default_value": "#1da613",
54+
"field_type": "color",
55+
"name": "cta_color",
56+
"label": "CTA color",
57+
"options": {
58+
"mode": "hex"
59+
}
60+
},
61+
{
62+
"default_value": "#0e59b4",
63+
"field_type": "color",
64+
"name": "msg_color",
65+
"label": "Message color",
66+
"options": {
67+
"mode": "hex"
68+
}
69+
}
70+
],
71+
"description": "",
72+
"options": {
73+
"html": "<div id=\"optimizely-extension-{{ extension.$instance }}\" class=\"cv-main\" style=\"background-color:{{ extension.overlay_color }}\">\n\t<div class=\"cv-modal\" style=\"background-color:{{ extension.modal_color }}\">\n\t\t<p class=\"cv-msg\" style=\"color:{{ extension.msg_color }}\">{{ extension.msg_copy }}</p>\n\t\t<a href=\"{{ extension.cta_url }}\" class=\"cv-cta\" style=\"background-color:{{ extension.cta_color }}\">{{ extension.text_cta }}</a>\n\t\t<a href=\"#\" class=\"cv-dismiss\">{{ extension.text_dismiss }}</a>\n\t</div>\n</div>",
74+
"css": ".cv-main{width:100%;height:100%;background-color:rgba(0,0,0,0.7);position:fixed;top:0;left:0;z-index:1000;display:none;}\n.cv-modal{width:700px;padding:40px;border:10px solid #999;background-color:#fff;position:absolute;top:50%;left:50%;margin:-180px 0 0 -360px;}\n.cv-msg{margin-bottom:30px;font-size:30px;line-height:40px;text-align:center;font-weight:bold;text-transform:uppercase;letter-spacing:-1px;}\n.cv-cta{width:300px;height:60px;margin:0 auto 30px auto;display:block;background-color:#0048f3;font-size:20px;line-height:60px;font-weight:bold;text-transform:uppercase;text-align:center;color:#fff!important;}\n.cv-cta:hover{opacity:0.8}\n.cv-dismiss{width:500px;display:block;margin:0 auto;font-size:12px;line-height:12px;text-align:center;color:#666}\n.cv-dismiss:hover{text-decoration:underline;} ",
75+
"apply_js": "$(document).ready(function() {\n $('body').prepend(extension.$html);\n \n $('.cv-main').fadeIn().promise().done(function() {\n localStorage.setItem('seenModal','true');\n });\n \n $('.cv-main, .cv-main .cv-dismiss').on('click',function(e) {\n e.preventDefault();\n\n if (e.target === this) {\n $('.cv-main').fadeOut();\n }\n });\n\n $('.cv-main .cv-cta').on('click',function(e) {\n e.preventDefault();\n\n window.location.replace($(this).prop('href'));\n });\n});",
76+
"undo_js": "var extensionHtml = document.getElementById('optimizely-extension-' + extension.$instance);\nif (extensionHtml) extensionHtml.remove();\n"
77+
}
78+
}
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Price Changer
2+
3+
![Screenshot](https://github.com/optimizely/extension-library/blob/master/Extensions/Editor%20Extensions/Price%20Changer/screenshot.png)
4+
5+
## Description
6+
7+
Extension that gives the ability to change prices for products site wide either by a discrete or a percentage amount.
8+
9+
__Please Note:__ This Extension is an example of how you can easily change prices in the UI that your visitors will see. This doesn't change the actual price in your backend code, so the original price will be charged if you don't change this in your backend. Also note that you might have to change the selector of the element that contains the prices in the _Apply JS_.
10+
11+
## Fields
12+
13+
* Price Change Type
14+
* Price Change Amount
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"plugin_type": "widget",
3+
"name": "Price changer",
4+
"edit_page_url": "http://playground.optimizely.how/",
5+
"form_schema": [
6+
{
7+
"default_value": "discrete",
8+
"field_type": "dropdown",
9+
"name": "priceChangeType",
10+
"label": "Price Change Type",
11+
"options": {
12+
"choices": [
13+
{
14+
"value": "discrete",
15+
"label": "Discrete"
16+
},
17+
{
18+
"value": "percentage",
19+
"label": "Percentage"
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"default_value": 0,
26+
"field_type": "number",
27+
"name": "priceChangeAmount",
28+
"label": "Price Change Amount",
29+
"options": null
30+
}
31+
],
32+
"description": "Ability to change the price of the products on the site",
33+
"options": {
34+
"apply_js": "var utils = optimizely.get('utils');\nvar $ = optimizely.get('jquery');console.log(extension);\n\nvar priceChange = extension.priceChangeAmount;\n\nfunction makePriceChange(originalPrice, quantity) {\n\tvar internalPriceChange = typeof quantity !== 'undefined' && extension.priceChangeType !== 'percentage' ? priceChange * quantity : priceChange;\n\t//console.log(parseFloat(originalPrice) + parseFloat(originalPrice * (internalPriceChange / 100)));\n\treturn extension.priceChangeType === \"discrete\" ? (originalPrice + internalPriceChange).toFixed(2) : (parseFloat(originalPrice) + parseFloat(originalPrice * (internalPriceChange / 100))).toFixed(2);\n}\n\nvar checkNormalPrices = setInterval(function() {\n\tvar prices = $('.product-price').length;\n\tif (prices > 0) {\n\t\tvar appliedPrices = $('.amended-price').length;\n\t\tif (prices !== appliedPrices) {\n\t\t\t$('.product-price:not(.amended-price)').each(function(index, el) {\n\t\t\t\tvar productPrice = parseFloat($(this).text().slice(1));\n\t\t\t\t$(this).text('$' + makePriceChange(productPrice)).addClass('amended-price');\n\t\t\t});\n\t\t}\n\t}\n}, 50);\n\nvar checkDiscountedPrices = setInterval(function() {\n\tvar prices = $('.product-price-discount').length;\n\tif (prices > 0) {\n\t\tvar appliedPrices = $('.amended-price').length;\n\t\tif (prices !== appliedPrices) {\n\t\t\t$('.product-price-discount:not(.amended-price)').each(function(index, el) {\n\t\t\t\tvar productPrices = $(this).text().match(/\\$([0-9]*\\.[0-9]*)\\$([0-9]*\\.[0-9]*)/);\n\n\t\t\t\tvar originalProductPrice = parseFloat(productPrices[1]);\n\t\t\t\tvar discountedProductPrice = parseFloat(productPrices[2]);\n\n\t\t\t\t$(this).html('$' + makePriceChange(originalProductPrice) + '<i>$' + makePriceChange(discountedProductPrice) + '</i>').addClass('amended-price');\n\t\t\t});\n\t\t}\n\t}\n}, 50);\n\nvar checkListPrices = setInterval(function() {\n\tvar prices = $('.product-list .product-list-desc i').length;\n\tif (prices > 0) {\n\t\tvar appliedPrices = $('.amended-price').length;\n\t\tif (prices !== appliedPrices) {\n\t\t\t$('.product-list .product-list-desc i:not(.amended-price)').each(function(index, el) {\n\t\t\t\tif ($(this).find('b').length > 0) { // Discounted prices\t\n\t\t\t\t\tvar productPrices = $(this).text().match(/\\$([0-9]*\\.[0-9]*)\\$([0-9]*\\.[0-9]*)/);\n\n\t\t\t\t\tvar originalProductPrice = parseFloat(productPrices[1]);\n\t\t\t\t\tvar discountedProductPrice = parseFloat(productPrices[2]);\n\n\t\t\t\t\t$(this).html('$' + makePriceChange(originalProductPrice) + '<b>$' + makePriceChange(discountedProductPrice) + '</b>').addClass('amended-price');\n\t\t\t\t} else {\n\t\t\t\t\tvar productPrice = parseFloat($(this).text().slice(1));\n\t\t\t\t\t$(this).text('$' + makePriceChange(productPrice)).addClass('amended-price');\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}, 50);\n\nvar checkCartPrices = setInterval(function() {\n\tvar prices = $('.cart-list li span').length;\n\tif (prices > 0) {\n\t\tvar appliedPrices = $('.amended-price').length;\n\t\tif (prices !== appliedPrices) {\n\t\t\t$('.cart-list li span:not(.amended-price)').each(function(index, el) {\n\t\t\t\tvar productPriceBreakdown = ($(this).text().match(/^([0-9]) x \\$(.*)/));\n\t\t\t\t\n\t\t\t\t$(this).text(productPriceBreakdown[1] + ' x $' + makePriceChange(parseFloat(productPriceBreakdown[2]))).addClass('amended-price');\n\t\t\t});\n\t\t}\n\n\t\tvar checkCart = setInterval(function() {\n\t\t\tvar price = $('#cart .cart-btn .button').length;\n\t\t\tif (price > 0) {\n\t\t\t\tvar appliedPrices = $('.amended-price').length;\n\t\t\t\tif (price !== appliedPrices) {\n\t\t\t\t\t$('#cart .cart-btn .button:not(.amended-price)').each(function(index, el) {\n\t\t\t\t\t\tvar productPrice = parseFloat($(this).text().slice(1));\n\t\t\t\t\t\t$(this).text('$' + makePriceChange(productPrice, $('.cart-list li span').length)).addClass('amended-price');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}, 50);\n\t}\n}, 50);",
35+
"html": "",
36+
"css": ".product-price,\n.product-price-discount,\n.product-list .product-list-desc i,\n#cart .cart-btn .button {\n\tdisplay: none;\n}\n\n.product-price.amended-price,\n.product-price-discount.amended-price,\n.product-list .product-list-desc i.amended-price,\n#cart .cart-btn .button.amended-price {\n\tdisplay: block;\n}",
37+
"undo_js": ""
38+
}
39+
}
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugin_type": "analytics_integration",
3+
"name": "econda Analytics Integration",
4+
"form_schema": [],
5+
"description": "",
6+
"options": {
7+
"track_layer_decision": "// Pre conditions :\n// 1: Econda-Tracking-Script is loaded before\n(function(){\n var decObject = window.optimizely.get(\"state\").getDecisionObject({campaignId: campaignId});\n if( typeof window.emos3 !== 'undefined'){\n window.emos3.send({ type: 'event', abtest: [ [decObject.experiment , decObject.variation] ] }); \n } else if (typeof(window.emosPropertiesEvent)== \"function\"){\n window.emosPropertiesEvent({ type: 'event', abtest: [ [decObject.experiment , decObject.variation] ] }); \n } else {\n console.log(\"Problem: econda A/B Test Tracking is activated but tracking library is not yet loaded. Could not send data to econda.\");\n }\n})();"
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Pre conditions :
2+
// 1: Econda-Tracking-Script is loaded before
3+
(function(){
4+
var decObject = window.optimizely.get("state").getDecisionObject({campaignId: campaignId});
5+
if( typeof window.emos3 !== 'undefined'){
6+
window.emos3.send({ type: 'event', abtest: [ [decObject.experiment , decObject.variation] ] });
7+
} else if (typeof(window.emosPropertiesEvent)== "function"){
8+
window.emosPropertiesEvent({ type: 'event', abtest: [ [decObject.experiment , decObject.variation] ] });
9+
} else {
10+
console.log("Problem: econda A/B Test Tracking is activated but tracking library is not yet loaded. Could not send data to econda.");
11+
}
12+
})();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Documentation
2+
3+
The documentation regarding this integration is available here: https://help.optimizely.com/Integrate_Optimizely_with_econda
4+
5+
Please note that this integration is in beta right now.

0 commit comments

Comments
 (0)