コンテンツにスキップ
アプリをインストール
日本語

アプリ関数

アプリは、あらゆる場所でコールバックやカスタマイズを可能にする複数の関数を提供しています。

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

このページは役に立ちましたか?

問題を報告