import { OnsiteCoreWindow } from "@mailbiz/onsite-core"; //#endregion //#region [Window] interface ShopifyWindow extends OnsiteCoreWindow { analytics: ShopifyPixelApiAnalytics; init: ShopifyPixelApiInit; checkout?: YampiCheckout; } //#endregion //#region [Shopify PixelApi] interface ShopifyPixelApiAnalytics { subscribe: { (eventName: "cart_viewed", callback: (event: ShopifyEvent) => void): void; (eventName: "checkout_address_info_submitted", callback: (event: ShopifyEvent) => void): void; (eventName: "checkout_completed", callback: (event: ShopifyEvent) => void): void; (eventName: "checkout_contact_info_submitted", callback: (event: ShopifyEvent) => void): void; (eventName: "checkout_shipping_info_submitted", callback: (event: ShopifyEvent) => void): void; (eventName: "checkout_started", callback: (event: ShopifyEvent) => void): void; (eventName: "collection_viewed", callback: (event: ShopifyEvent) => void): void; (eventName: "page_viewed", callback: (event: ShopifyEvent) => void): void; (eventName: "payment_info_submitted", callback: (event: ShopifyEvent) => void): void; (eventName: "product_added_to_cart", callback: (event: ShopifyEvent) => void): void; (eventName: "product_removed_from_cart", callback: (event: ShopifyEvent) => void): void; (eventName: "product_viewed", callback: (event: ShopifyEvent) => void): void; (eventName: "search_submitted", callback: (event: ShopifyEvent) => void): void; }; } interface ShopifyPixelApiInit { context: { document: { location: { href: string; hash: string; host: string; hostname: string; origin: string; pathname: string; port: string; protocol: string; search: string; }; referrer: string; characterSet: string; title: string; }; navigator: { language: string; cookieEnabled: boolean; languages: Array; userAgent: string; }; window: { innerHeight: number; innerWidth: number; outerHeight: number; outerWidth: number; pageXOffset: number; pageYOffset: number; location: { href: string; hash: string; host: string; hostname: string; origin: string; pathname: string; port: string; protocol: string; search: string; }; origin: string; screen: { height: number; width: number; }; screenX: number; screenY: number; scrollX: number; scrollY: number; }; }; data: { customer: ShopifyCustomer | null; cart: ShopifyCart | null; }; customerPrivacy: { analyticsProcessingAllowed: true; marketingAllowed: true; preferencesProcessingAllowed: true; saleOfDataAllowed: true; }; } //#endregion //#region [Shopify Events] type ShopifyEventData = ShopifyCartChangedEventData | ShopifyProductViewedEventData | ShopifyCheckoutEventData | ShopifyNoEventData | void; interface ShopifyCartChangedEventData { cartLine: ShopifyCartLine; } interface ShopifyProductViewedEventData { productVariant: ShopifyMerchandise; } interface ShopifyCheckoutEventData { checkout: ShopifyCheckout; } type ShopifyNoEventData = undefined; interface ShopifyEvent { id: string; name: string; type: string; clientId: string; timestamp: string; data: T; context: { document: { location: { href: string; hash: string; host: string; hostname: string; origin: string; pathname: string; port: string; protocol: string; search: string; }; referrer: string; characterSet: string; title: string; }; navigator: { language: string; cookieEnabled: boolean; languages: Array; userAgent: string; }; window: { innerHeight: number; innerWidth: number; outerHeight: number; outerWidth: number; pageXOffset: number; pageYOffset: number; location: { href: string; hash: string; host: string; hostname: string; origin: string; pathname: string; port: string; protocol: string; search: string; }; origin: string; screen: { height: number; width: number; }; screenX: number; screenY: number; scrollX: number; scrollY: number; }; }; } //#endregion //#region [Shopify Cart] interface ShopifyCart { id: string; cost: ShopifyCost; lines: ShopifyCartLine[]; totalQuantity: number; } interface ShopifyCartLine { cost: ShopifyCost; merchandise: ShopifyMerchandise; quantity: number; } interface ShopifyCost { totalAmount: ShopifyAmountAndCurrency; } interface ShopifyMerchandise { id: string; image: { src: string; }; price: ShopifyAmountAndCurrency; product: ShopifyProduct; sku?: string; title: string; untranslatedTitle: string; } interface ShopifyAmountAndCurrency { amount?: number; currencyCode?: string; } interface ShopifyProduct { id: string; title: string; untranslatedTitle: string; url: string; vendor: string; type: string; } //#endregion //#region [Shopify Customer] interface ShopifyCustomer { email: string | null; firstName: string | null; id: string | null; lastName: string | null; phone: string | null; ordersCount: number; } //#endregion //region [Shopify Checkout] interface ShopifyCheckout { attributes: Array; billingAddress: { country: string; countryCode: string; province: string; provinceCode: string; }; token: string; currencyCode: string; discountApplications: Array<{ allocationMethod: string; targetSelection: string; targetType: string; title: string; type: string; value: ShopifyAmountAndCurrency; }>; email: string | null; phone: string | null; lineItems: ShopifyCheckoutLine[]; order: { customer: { id?: string; }; id?: string; }; shippingAddress: { address1?: string | null; address2?: string | null; city?: string | null; country?: string | null; countryCode?: string | null; firstName?: string | null; lastName?: string | null; phone?: string | null; province?: string | null; provinceCode?: string | null; zip?: string | null; neighborhood?: string | null; number?: string | null; }; subtotalPrice: ShopifyAmountAndCurrency; shippingLine: { price: ShopifyAmountAndCurrency; }; totalTax: ShopifyAmountAndCurrency; totalPrice: ShopifyAmountAndCurrency; transactions: Array<{ amount: ShopifyAmountAndCurrency; gateway: string; }>; } interface ShopifyCheckoutLine { title: string; variant: ShopifyMerchandise; quantity: number; id?: string; discountAllocations?: any[]; } //region [Yampi checkout] interface YampiCheckout { referrer_url: string; cart: YampiCheckoutCart; state: YampiCheckoutState; orderPlaced?: YampiCheckoutOrderPlaced; orderbump: any; } interface YampiCheckoutCart { id: number; model?: YampiCheckoutCartModel; customer_id: any; token: string; optionsIds: string[]; url?: string; utm_source?: any; utm_campaign?: any; items: YampiCheckoutCartItem[]; next_available_freebies?: any[]; grouped_items?: GroupedItems; installments?: YampiCheckoutInstallments; discounts_labels?: string; by_pass_payment?: boolean; discounts: Discount[]; prices: YampiCheckoutCartPrices; cashback: YampiCheckoutCartCashback; customer?: YampiCheckoutCustomer; cart_discounts?: YampiCheckoutCartCartDiscount[]; } interface YampiCheckoutCustomer { id: number; first_name: string; last_name: string; document: string; document_type: string; birthday: string; phone_number: string; wallet_balance: number; full_name: string; email: string; } interface YampiCheckoutCartModel extends YampiCheckoutCartModelItemCart { items: YampiCheckoutCartModelItem[]; payment: any; kits: any[]; store: YampiCheckoutCartModelStore; address: YampiCheckoutCartModelAddress; } interface YampiCheckoutCartModelAddress { id: number; customer_id: number; receiver: string; zip_code: string; street: string; number: string; complement: string; reference: any; neighborhood: string; city: string; uf: string; created_at: string; updated_at: string; deleted_at: any; } interface YampiCheckoutCartModelItem { id: number; cart_id: number; product_option_id: number; kit_id: any; upsell_id: any; bundle_id: any; quantity: number; gift: number; has_recomm: number; custom_value: any; created_at: string; updated_at: string; freebie_id: any; product_option: YampiCheckoutCartModelItemProductOption; customizations: any[]; cart: YampiCheckoutCartModelItemCart; discounts: any[]; } interface YampiCheckoutCartModelItemProductOption { id: number; store_id: number; product_id: number; sku: string; token: string; barcode: any; allow_sell_without_customization: number; price_sale: string; price_discount: string; quantity_managed: number; availability: number; availability_soldout: number; blocked_sale: number; order: number; created_at: string; updated_at: string; } interface YampiCheckoutCartModelItemCart { id: number; store_id: number; customer_id: any; promocode_id: number | null; promocode?: YampiCheckoutCartModelItemCartPromocode | null; payment_id: any; address_id: any; seller_id: any; done: number; token: string; has_recomm: number; value_shipment: any; zipcode: any; shipment_service_id: any; payment_alias: any; tracking_data: any; utm_source: any; utm_campaign: any; utm_medium: any; utm_term: any; utm_content: any; created_at: string; updated_at: string; deleted_at: any; customer?: YampiCheckoutCartModelItemCartCustomer; } interface YampiCheckoutCartModelItemCartCustomer { id: number; store_id: number; marketplace_id: any; active: number; type: string; cluster_id: any; name: string; cpf: string; rg: any; razao_social: any; cnpj: any; state_registration: string; email: string; homephone: string; birthday: string; newsletter: number; sms: number; whatsapp: number; social_driver: any; social_id: any; avatar_url: string; confirmed: number; ip: string; utm_source: string; utm_campaign: any; notes: any; created_at: string; updated_at: string; deleted_at: any; cluster: any; } interface YampiCheckoutCartModelItemCartPromocode { id: number; store_id: number; customer_id: any; active: number; for_the_price_of: number; cart_default: number; description: string; type_increment_value: string; value: string; price_products: string; percent_products: string; code: string; quantity: number; product_quantity: number; product_max_quantity: number; used: number; items_count: number; min_value: string; shipment_percent: string; accumulate: number; once_per_customer: number; abandoned_cart: number; newsletter: number; free_shipment: number; ignore_promotion_products: number; start_at: string; end_at: string; created_at: string; updated_at: string; deleted_at: any; } interface YampiCheckoutCartModelStore { id: number; store_type_id: any; template_id: any; theme_id: any; preset_id: any; active: number; internal_active: number; is_subdomain: number; is_published: number; corporate: number; is_marketplace: number; use_only_checkout: number; profile: string; alias: string; domain: string; suspended_at: any; created_at: string; deleted_at: any; open_code_theme: any; use_open_code: any; flow_stage: any; flow_started_at: any; hubspot_id: string; checkout_config: YampiCheckoutCartModelStoreCheckoutConfig; cashback_rule: any; } interface YampiCheckoutCartModelStoreCheckoutConfig { id: number; store_id: number; active: number; currency: string; show_shipping_in_cart: number; show_shipping_time: number; show_installment_warning: number; auto_shipping_selection: number; sequential_sale_number: number; delivery_working_days: number; max_daily_sales_by_ip: number; max_items_per_order: number; show_products_links: number; show_promocode: number; show_birthday: number; show_delivery_date: number; password_required: number; accumulate_discounts: number; select_largest_installment: number; always_requires_address: number; use_product_brand: number; quantity_controls: number; skip_cart: number; single_order_bump: number; active_rebuy: number; card_discount: string; billet_discount: string; pix_discount: string; pix_in_installments_discount: string; wallet_discount: string; person_type: string; payment_auto_selected: any; brand_url: string; text_header: string; analytics_id: any; gtm_id: any; chaordic_key: any; ebit_seal: any; chat_script: any; custom_css: any; text_footer: any; text_shipping: string; text_billet: string; text_card: any; header_text_background: string; button_color: string; phone: any; redirect_url_billet: any; redirect_url_card: any; redirect_url_deposit: any; redirect_url_pix_in_installments: any; redirect_url_upsell: any; stopwatch_minutes: number; domain: string; custom_script: any; custom_thankyou_script: any; custom_metatags: any; created_at: string; updated_at: string; has_checkout_first_step_discount: number; show_original_price_when_free_shipping: number; } interface YampiCheckoutCartItem { id: number; cart_id: number; product_option_id: number; kit_id: any; bundle_id: any; upsell_id: any; freebie_id: any; quantity: number; gift: number; created_at: string; updated_at: string; brand: YampiCheckoutCartItemBrand; is_in_promotional_rack: boolean; custom_shipping: boolean; free_shipping: boolean; shipping_price: number; weight: number; product_id: number; option_id: number; link: string; is_bundle: boolean; is_freebie: boolean; freebie: any; group_name: string; product_metadata: any[]; metadata: any[]; bundle: Bundle; small: string; thumb: string; medium: string; has_price_discount: boolean; price_gift: any; price_gift_formated: string; price_sale: string; price_sale_formated: string; price: string; price_total: number; price_total_with_item_discount: number; price_formated: string; price_total_formated: string; name: string; name_with_grids: string; sku: string; availability_days: number; availability_text: string; categories: number[]; categories_names: string[]; grids: Grid[]; is_digital: boolean; short_description: string; rack_ids: any[]; customizations: any[]; customized: boolean; allow_sell_without_customization: number; selected_customizations: number; order_bump_id: any; shopify_variant_id: string | null; shopify_product_id: string | null; product_option: YampiCheckoutCartItemProductOption; cart: YampiCheckoutCartModelItemCart; discounts: any[]; } interface YampiCheckoutCartItemBrand { id: number; name: string; slug: string; } interface Bundle { name: string; modifiable: boolean; image_url: string; quantity: number; shipping: Shipping; } interface Shipping { custom: boolean; price: number; days: any; type: any; } interface Grid { name: string; value: string; } interface YampiCheckoutCartItemProductOption { id: number; store_id: number; product_id: number; price_sale: string; price_discount: string; sku: string; quantity_managed: number; availability: number; availability_soldout: number; allow_sell_without_customization: number; product: Product; stocks?: Stock[]; } interface Product { id: number; name: string; slug: string; gift_value: any; is_digital: number; seo_description: string; brand_id: number; facebook_pixel_id: any; custom_shipping: number; shipping_price: string; store_id: number; simple: number; brand: Brand2; } interface Brand2 { id: number; store_id: number; active: number; featured: number; name: string; description: any; logo: any; created_at: string; updated_at: string; deleted_at: any; } interface Stock { id: number; option_id: number; stock_id: number; quantity: number; min_quantity: number; created_at: string; updated_at: string; } interface GroupedItems { [productName: string]: YampiCheckoutCartItem; } interface YampiCheckoutInstallments { max_installment: number; max_installment_value: string; amount: string; text: string; text_with_tax: string; text_discount_percent: any; text_discount: any; formula: string; installments: YampiCheckoutCartInstallment[]; } interface YampiCheckoutCartInstallment { amount: string; amount_formated: string; base_value: string; tax: string; tax_value: number; discount_percent: string; discount_value: string; discount_value_formated: string; installment: number; installment_value: string; installment_value_formated: string; text: string; text_with_tax: string; text_discount_percent: any; text_discount: any; } interface Discount { name: string; value: number | string; accumulate: boolean; } interface YampiCheckoutCartPrices { items_amount: number; total_items: string; subtotal: number; discount: number; discount_without_wallet: number; items_discount: number; shipment: number; shipment_original_value: any; shipment_discount_value: number; shipment_discount_percent: string; promocode_discount_value: number | string; progressive_discount_value: number; kits_discount_value: number; total: number; value_for_free_shipment: number; installments: YampiCheckoutInstallments; promocode_subtotal: any; items_amount_formated: string; subtotal_formated: string; items_discount_formated: string; discount_formated: string; shipment_original_value_formated: string; shipment_formated: string; total_format: string; total_formated: string; value_for_free_shipment_formated: string; } interface YampiCheckoutCartCashback { has_offer: boolean; value: number; } interface YampiCheckoutCartCartDiscount { percent_discount: number; percent_discount_formated: string; name: string; alias: string; prices: YampiCheckoutCartCartDiscountPrices; } interface YampiCheckoutCartCartDiscountPrices { price_discount: number; total: number; total_without_discount: number; } interface YampiCheckoutState { updateDomAfterInstallmentLoad: boolean; eventsInitialized: boolean; } interface YampiCheckoutOrderPlaced { id: number; token: string; payment_method: string; new_customer: boolean; coupon: string; number: string; total: number; total_without_taxes: number; total_without_shipping: number; customer_id: number; customer: YampiCheckoutOrderPlacedCustomer; authorized: number; optionsIds: string[]; skusIds: string[]; status: string; prices: YampiCheckoutOrderPlacedPrices; address_info: YampiCheckoutOrderPlacedAddressInfo; items: YampiCheckoutOrderPlacedItem[]; } interface YampiCheckoutOrderPlacedCustomer { id: number; first_name: string; last_name: string; document: string; document_type: string; birthday: string; phone_number: string; wallet_balance: number; full_name: string; email: string; } interface YampiCheckoutOrderPlacedPrices { total: number; } interface YampiCheckoutOrderPlacedAddressInfo { hashed_first_name: string; hashed_last_name: string; hashed_street_address: string; city: string; state: string; postal_code: string; country_code: string; } interface YampiCheckoutOrderPlacedItem { product: YampiCheckoutOrderPlacedItemProduct; quantity: number; name: string; product_id: number; categories_names: string[]; } interface YampiCheckoutOrderPlacedItemProduct { id: string; sku: string; price: number; brand: string; categories: string[]; image_url: string; metadata: any[]; } declare global { interface Window extends ShopifyWindow { } }