pattern="/^\d{5}(?:-\d{4})?$/"
pattern="[^@\s]+@[^@\s]+\.[^@\s]+"
| public without sharing class B2BCheckout { | |
| @AuraEnabled | |
| public static CartDeliveryGroup setPickupInformation(String notes, String pickupTime, Id cartDeliveryGroupId) { | |
| CartDeliveryGroup cartDeliveryGroup = [ | |
| SELECT Id, DeliveryMethodId | |
| FROM CartDeliveryGroup | |
| WHERE Id =: cartDeliveryGroupId | |
| ]; | |
| Datetime desiredDeliveryDate = Datetime.valueOfGmt(pickupTime.replace('T', ' ')); | |
| cartDeliveryGroup.ShippingInstructions = notes; |
| // Using add itemS to cart from the commerce/cartApi | |
| import { addItemsToCart } from "commerce/cartApi"; | |
| // Set up an array as a payload. | |
| const payload = [{ | |
| productId: this.productId, | |
| quantity: this.quantity, | |
| type: "Product" | |
| }]; |
| /* Returns a promise */ | |
| fetchCommerceUrl(url) { | |
| let apiver = 'v64.0'; | |
| let commercebase = '/webruntime/api/services/data/' + apiver + '/commerce'; | |
| let fullurl = commercebase + url; | |
| console.log('Begin fetchCommerceUrl on ', fullurl); | |
| return fetch(fullurl, { | |
| method: 'GET', |
| import checkoutApi from "commerce/checkoutApi"; | |
| import cartApi from "commerce/cartApi"; | |
| console.log("cartApi:", cartApi); | |
| console.log("cartApi keys:", Object.keys(cartApi)); | |
| // Optional: Log function names individually | |
| Object.keys(cartApi).forEach((key) => { | |
| console.log(`cartApi[${key}] =`, cartApi[key]); | |
| }); |
| /** | |
| * Wraps the startViewTransition to check avialability and reduced motion settings. | |
| * Usage: await viewTransition(() => {this.showElement = true}); | |
| * @param {Function} callback - callback to function that triggers the animation. | |
| * @returns {Promise<unknown>} - Finish transition. | |
| */ | |
| export const viewTransition = (callback) => { | |
| return new Promise((resolve) => { | |
| const mediaQuery = window.matchMedia('(prefers-reduced-motion)'); | |
| const isReducedMotion = mediaQuery.matches; |
| import { LightningElement } from 'lwc'; | |
| export default class BrowserNotificationsExample extends LightningElement { | |
| connectedCallback() { | |
| this.initPushNotifications(); | |
| } | |
| // Modified from: https://levelup.gitconnected.com/creating-browser-notification-in-javascript-79e91bfb76c8 | |
| initPushNotifications() { |
| const stdTimezoneOffset = (date) => { | |
| const jan = new Date(date.getFullYear(), 0, 1); | |
| const jul = new Date(date.getFullYear(), 6, 1); | |
| return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); | |
| }; | |
| const isDstObserved = (date) => date.getTimezoneOffset() < stdTimezoneOffset(date); | |
| const offset = start.getTimezoneOffset(); | |
| const start = new Date(start.getTime() - (offset*60*1000)); |