콘텐츠로 이동
앱 설치
한국어

앱 함수

앱은 어디서든 콜백과 사용자 지정을 할 수 있도록 여러 함수를 정의합니다.

AI 개요

사용자 지정 테마 코드에서 호출하여 사전 주문 요소를 다시 렌더링하고 제품 프로필, 결제 옵션, 메시지를 가져올 수 있는 앱 함수를 소개합니다.

  • 앱을 삭제해도 사용자 지정 코드가 깨지지 않도록 항상 Globo와 Globo.Preorder가 존재하는지 확인하거나 코드를 try-catch로 감싸세요.
  • Globo.Preorder.initPreorder()는 이형 상품 변경 후 제품 페이지를 다시 렌더링하고, Globo.Preorder.initCollection()은 필터링, 정렬, 페이지 이동 후 다시 렌더링합니다.
  • Globo.Preorder.searchProductByJson()은 ID 또는 핸들로 제품을 가져오므로 제품을 추가하고 컬렉션 페이지를 다시 렌더링할 수 있습니다.
  • Globo.Preorder.getResolvedProfile()에는 productJson과 variantId가 필요하며, 제품이 사전 주문 중인지, 출시 예정인지, 날짜 또는 수량으로 종료되었는지를 알려 줍니다.
  • 프로필은 현재 로캘에 맞는 결제 옵션, 할인, 번역된 메시지도 반환합니다.

AI가 생성한 요약입니다. 오류가 있을 수 있으니 아래 전체 가이드를 확인하세요.

* 함수를 올바르게 호출하기

앱을 제거하더라도 사용자 지정 코드가 항상 작동하도록, 추가한 코드는 테마에 영향을 주지 않습니다. 이 점은 매우 중요합니다!

// Always check if the application is installed before calling the app function.
if(typeof Globo != 'undefined' && typeof Globo.Preorder != 'undefined'){
// code here
}
  • 또는 try-catch 블록으로 사용자 지정 코드를 감싸 예외 오류를 방지할 수도 있습니다.
try{
// code here
} catch (error) {}

1. 제품 페이지에서 다시 렌더링

경우에 따라 이형 상품을 변경한 후 앱 테마가 다시 렌더링되지 않습니다.

// after variant changed 
if(typeof Globo != 'undefined' && typeof Globo.Preorder != 'undefined'){
 Globo.Preorder.initPreorder();
}

2. 컬렉션 페이지에서 다시 렌더링

경우에 따라 컬렉션 필터링, 정렬, 페이지 이동 후 앱 테마가 다시 렌더링되지 않습니다.

// after filtering, paginate, sort 
if(typeof Globo != 'undefined' && typeof Globo.Preorder != 'undefined'){
 Globo.Preorder.initCollection();
}
  • 푸터의 추천 제품에도 이 코드를 같은 방식으로 사용하세요.

3. 도우미 함수

1. 제품 검색

  • Globo.Preorder.searchProductByJson(chunkProducts = [])
  • 예시
const chunkProducts = [
'id:"gid://shopify/Product/123"',
// ...,
'handle:"puma-runner"',
]
const products = await Globo.Preorder.searchProductByJson(chunkProducts)
if(products.length > 0){
// Push data to list product & re-render on collection page
const currentProductIds = new Set(
Globo.Preorder.settings.products.map(product => product.id)
);
const newProducts = products.filter(
product => product && !currentProductIds.has(product.id)
);
Globo.Preorder.settings.products.push(...newProducts);
Globo.Preorder.initCollection();
}

2. 제품 프로필 가져오기

  • productJson과 variantId가 필요합니다.
  • Globo.Preorder.getResolvedProfile(productJson, variantId)
  • 제품 프로필을 가져오고 제품 상태를 확인하는 예시
const profile = Globo.Preorder.getResolvedProfile(productJson, variantId);
if(!profile){
// The current product is not included any profile, or the profile status is draft.
} else if(profile && (typeof profile.isPreorder == 'undefined' || (!profile.isPreorder && (profile?.isComingSoon ?? false)))){
// profile is coming soon add to cart
} else {
// profile is pre-order and
if(!profile.isPreorder && profile.endedByCondition == 'date'){
// Product is ended preorder by date
} else if (!profile.isPreorder && profile.endedByCondition == 'quantity') {
// Product is ended preorder by quantity condition
} else if (!profile.isPreorder && profile.startCondition == 'date' ) {
// Product is preorder and coming soon preorder
} else if (!profile.isPreorder && (profile.startCondition == 'quantity' || profile.startCondition == 'stock')){
// Product is preorder and coming soon preorder
} else if (profile.isPreorder) {
// Product is preorder
}
}

3. 결제 옵션 및 사전 주문 제품 할인 가져오기

const profile = Globo.Preorder.getProductProfile(productJson, variantId);
let discountPayment = profile.discountPayment;
// data format discountPayment
// {
// "display": {
// hidePaymentOptions: false, // [true, false]
// showComparePrice: true // [true, false]
// },
// "fullPayment": {
// "enable": true, // [true, false]
// "discountValue": "0", // number
// "discountType": "percentage" // ["percentage", "fixed"]
// },
// "partialPayment": {
// "enable": false, // [true, false]
// "value": "10", // number
// "valueType": "percentage", // ["percentage", "fixed"]
// "discountValue": "0", // number
// "discountType": "percentage", // ["percentage", "fixed"]
// "remainingBalanceChargeTrigger": "EXACT_TIME", // ["MANUAL", "EXACT_TIME", "TIME_AFTER_CHECKOUT"]
// "remainingBalanceChargeExactTime": "2026-08-30", // specific date string - set when remainingBalanceChargeTrigger == "EXACT_TIME"
// "remainingBalanceChargeTimeAfterCheckoutType": "week", // ["day", "week", "month"] - set when remainingBalanceChargeTrigger == "TIME_AFTER_CHECKOUT"
// },
// "display": {
// "hidePaymentOptions": false,
// "showComparePrice": true
// }
// }

4. 메시지 가져오기

  • 기본 번역 메시지를 가져오려면 Globo.Preorder.settings.translation을 사용하세요.
  • 프로필별 메시지를 가져오면 현재 로캘로 번역된 최종 텍스트입니다.
const profile = Globo.Preorder.getResolvedProfile(productJson, variantId);
const message = profile.message;
// data message example
// {
// "preorderText": "Pre Order",
// "messageAboveText": "Don't miss out - Grab yours now before we sell out again!",
// "messageBellowText": "We will fulfill the item as soon as it becomes available",
// "naMessageText": "Not available for Pre order",
// "comingSoonText": "Coming soon",
// "comingSoonAddToCartText": "Coming soon",
// "soldoutText": "Sold out",
// "preorderLimitMessage": "Only :stock items left in stock",
// "outOfStockMessage": "Inventory level is :stock.It is less than you are trying to purchase. Some of the items will be pre-ordered. Continue?",
// "labelCountdownStart": "Coming soon",
// "labelCountdownEnd": "Pre-Order ending in",
// "labelCountdownDays": "Days",
// "labelCountdownHours": "Hours",
// "labelCountdownMinutes": "Minutes",
// "labelCountdownSeconds": "Second",
// "preorderBadge": "Pre Order",
// "preorderLabel": "Pre-order",
// "preorderedItemlabel": "Pre-order item",
// "preorderContactLink": "Reach out for more information →",
// "cartWarningTitle": "Warning: you have pre-order and in-stock in the same cart",
// "cartWarningContent": "Shipment of your in-stock items may be delayed until your pre-order item is ready for shipping.",
// "cartWarningCheckboxLabel": "Don't show this again",
// "partialPaymentLabel": "Payment option",
// "partialPaymentOptionFull": "Full Payment",
// "partialPaymentOptionPart": "Partial Payment",
// "preorderPrice": "PreOrder Price",
// "partialPaymentTitle": "Prepaid amount for {{product.title}} ({{variant.title}})",
// "cartWarningLimitMessage": "There are still :stock pre-order items that can be added to the cart",
// "cartWarningEndLimitMessage": "The number of products that can be pre-ordered has reached the limit",
// "cartWarningAlertMessage": "There are still :stock pre-order items that can be added to the cart. You can purchase up to :max products",
// "bisTextButton": "Email me when available",
// "bisTitleForm": "Email me when available",
// "bisHeaderContent": "Register your email address below to receive an email as soon as this becomes available again",
// "bisPlaceHolderEmail": "Enter your email",
// "bisSubscribeTextButton": "SUBSCRIBE",
// "bisFooterContent": "We will send you an email once the product becomes available. Your email address will not be shared with anyone else",
// "bisSubscribeSuccess": "Your notification has been registered",
// "bisSubscribeFail": "The email address you entered is invalid",
// "bisSubscribeRegistered": "Your email address is registered on this product",
// "bisSubscribeRequired": "The email address is required",
// "bisPhoneRegistered": "Your phone is registered on this product",
// "bisEmailAlertTitle": "Email",
// "bisSmsAlertTitle": "SMS",
// "partialPaymentSaveLavel": "Save",
// "emailPlaceholderBisForm": "Enter your email",
// "partialPaymentReleased": "You will be charged the remaining balance when the product is released on {{ released }}",
// "unsubscribeTitle": "<b>{{ email }}</b><br>will be unsubscribe from the <b>{{ shop_name }}</b> shop listings",
// "unsubscribeButton": "Unsubscribe",
// "unsubscribeSuccess": "You have successfully unsubscribed. Please re-register the product to receive notification",
// "unsubscribeProductUnsubscribed": "You have unsubscribed from this product"
// }

5

도움이 되었나요?

문제 신고