Skip to content

Instantly share code, notes, and snippets.

Avatar

Shopify Partners shopifypartners

View GitHub Profile
@shopifypartners
shopifypartners / pos-toast-notices.js
Created Jan 28, 2020
Setting POS toast notices (with App Bridge)
View pos-toast-notices.js
const toastNoticeOptions = {
message: 'Product saved',
duration: 5000,
};
const toastNotice = Toast.create(app, toastNoticeOptions);
const toastErrorOptions = {
message: 'Error saving',
duration: 5000,
@shopifypartners
shopifypartners / setting-pos-discounts.js
Created Jan 28, 2020
Setting POS discounts (with App Bridge)
View setting-pos-discounts.js
var discountPayload = {
amount: '1',
discountDescription: "$1 off discount",
type: 'flat',
}
var unsubscriber = cart.subscribe(Cart.Action.UPDATE, function (payload: Cart.Payload) {
console.log('[Client] setDiscount', payload);
unsubscriber();
});
cart.dispatch(Cart.Action.SET_DISCOUNT, {
@shopifypartners
shopifypartners / adding-pos-cart-items.js
Created Jan 28, 2020
Adding POS cart items (with App Bridge)
View adding-pos-cart-items.js
var unsubscriber = cart.subscribe(Cart.Action.UPDATE, function (payload: Cart.Payload) {
console.log('[Client] setLineItemProperties', payload);
unsubscriber();
});
cart.dispatch(Cart.Action.SET_LINE_ITEM_PROPERTIES, {
index: 0,
data: {
referral: 'Shopify',
userID: '1234',
}
@shopifypartners
shopifypartners / manage-pos-line-items.js
Created Jan 28, 2020
Manage POS line items (with App Bridge)
View manage-pos-line-items.js
var lineItemPayload = {
variantId: '1234',
quantity: 1
};
var unsubscriber = cart.subscribe(Cart.Action.UPDATE, function (payload: Cart.Payload) {
console.log('[Client] addLineItem', payload);
unsubscriber();
});
cart.dispatch(Cart.Action.ADD_LINE_ITEM, {
View ambient-light-simple-demo.js
if ( 'AmbientLightSensor' in window ) {
const sensor = new AmbientLightSensor();
sensor.onreading = () => {
if ( sensor.illuminance < 20) {
element.style.setProperty('--bg', 'black’);
} else {
element.style.setProperty('--bg', 'blue’);
}
};
sensor.start();
View ambient-light-simple-demo.js
if ( 'AmbientLightSensor' in window ) {
const sensor = new AmbientLightSensor();
sensor.onreading = () => {
if ( sensor.illuminance < 20) {
element.style.setProperty('--bg', 'black’);
} else {
element.style.setProperty('--bg', 'blue’);
}
};
sensor.start();
@shopifypartners
shopifypartners / announcement-bar.liquid
Created Oct 25, 2019
How to Create a Customizable Announcement Bar Section
View announcement-bar.liquid
<style>
.announcement-bar {
background-color: {{ section.settings.announcement_bar_color }};
text-align: center;
text-decoration: none;
}
.announcement-bar__message {
font-size: large;
padding: 10px;
color: {{ section.settings.announcement_bar_text_color }};
@shopifypartners
shopifypartners / announcement-bar-style.liquid
Created Oct 25, 2019
How to Create a Customizable Announcement Bar Section
View announcement-bar-style.liquid
<style>
.announcement-bar {
background-color: {{ section.settings.announcement_bar_color }};
}
</style>
@shopifypartners
shopifypartners / colour-setting.liquid
Created Oct 25, 2019
How to Create a Customizable Announcement Bar Section
View colour-setting.liquid
{
"type": "color",
"id": "announcement_bar_color",
"label": "Background color",
"default": "#000000"
},
@shopifypartners
shopifypartners / text-link-section-settings.liquid
Created Oct 25, 2019
How to Create a Customizable Announcement Bar Section
View text-link-section-settings.liquid
You can’t perform that action at this time.