$w.ProductPage

$w.ProductPage

A store page for a specific product.

Mixes In

$w.Element, $w.HiddenCollapsedMixin

Contents

collapsed Indicates if the element is collapsed or expanded.
global Indicates if an element appears on all pages or only on the current page.
hidden Indicates if the element is visible or hidden.
id Gets the elements's ID.
isVisible Indicates if the element is actually visible.
parent Gets the element's parent element.
rendered Indicates if an element is currently displayed.
type Gets the element's type.
collapse( ) Collapses the element and sets its collapsed property to true.
expand( ) Expands the element and sets its collapsed property to false.
getProduct( ) Gets the all the information associated with the currect product.
hide( ) Hides the element and sets its hidden property to true, using an effect if specified.
onMouseIn( ) Adds an event handler that runs when the mouse pointer is moved onto the element.
onMouseOut( ) Adds an event handler that runs when the mouse pointer is moved off of the element.
onViewportEnter( ) Adds an event handler that runs when an element is displayed in the viewable part of the current window.
onViewportLeave( ) Adds an event handler that runs when an element is no longer displayed in the viewable part of the current window.
scrollTo( ) Scrolls the page to the element using an animation.
show( ) Shows the element and sets its hidden property to false, using an effect if specified.
StoreProduct An object representing a product in a store.
StoreProductAdditionalInfoSection An object representing an additional info section for a store product.
StoreProductCustomTextFields An object representing a custom text field for a store product.
StoreProductOption An object representing an option for a store product.
StoreProductOptions An object representing all the available options for a store product.
StoreProductOptionsChoice An object representing an additional info section for a store product.
StoreProductOptionsChoiceMedia An object representing the choice media
StoreProductRibbon An object representing a ribbon for a store product.
collapsed

collapsed

Indicates if the element is collapsed or expanded.

Syntax

get collapsed(): boolean

Description

If collapsed is true, the element is not displayed on the page under any circumstances. A collapsed element, unlike a hidden element, does not take up any space on the page. When collapsed, elements positioned within 70 pixels below the collapsed element and each other move up to take the collapsed element's place where possible. The elements that move up maintain their positions relative to one another.

If collapsed is false, the element may be displayed on the page. Elements that moved up to take the collapsed element's place on the page are moved back down.

However, an expanded element (an element whose collapsed property is false) is still not displayed if:

Even if the element is not be displayed due to the conditions mentioned above, if its collapsed property is false, it's displayed when the conditions no longer apply.

To set the collapsed property on an element, use the element's collapse() and expand() functions.

If you select Collapsed on load in the element's Properties panel in the Editor, the collapsed property is set to true when the page loads.

Type

Boolean

Examples

Get an element's collapsed status

bGV0IGlzQ29sbGFwc2VkID0gJHcoIiNteUVsZW1lbnQiKS5jb2xsYXBzZWQ7IC8vIGZhbHNlCg==
let isCollapsed = $w("#myElement").collapsed; // false

Toggle an element's collapsed state

aWYoICR3KCIjbXlFbGVtZW50IikuY29sbGFwc2VkICkgewogICR3KCIjbXlFbGVtZW50IikuZXhwYW5kKCk7Cn0KZWxzZSB7CiAgJHcoIiNteUVsZW1lbnQiKS5jb2xsYXBzZSgpOwp9Cg==
if( $w("#myElement").collapsed ) {
  $w("#myElement").expand();
}
else {
  $w("#myElement").collapse();
}

Default Value

false

Mixed In From

$w.HiddenCollapsedMixin

See Also

collapse( ), expand( ), hide( ), show( ), hidden

global

global

Indicates if an element appears on all pages or only on the current page.

Syntax

get global(): boolean

Description

If global is true, the element appears on all pages.

If global is false, the element only appears on the current page.

Type

Boolean

Examples

Get whether an element is displayed on all pages

bGV0IGlzR2xvYmFsID0gJHcoIiNteUVsZW1lbnQiKS5nbG9iYWw7IC8vIGZhbHNlCg==
let isGlobal = $w("#myElement").global; // false

Default Value

false

Mixed In From

$w.Element

hidden

hidden

Indicates if the element is visible or hidden.

Syntax

get hidden(): boolean

Description

If hidden is true, the element is not displayed on the page under any circumstances. A hidden element, unlike a collapsed element, continues to take up the same space on the page as it did when it was visible.

If hidden is false, the element may be displayed on the page.

However, an element whose hidden property is false is still not displayed if:

Even if the element is not displayed due to the conditions mentioned above, if its hidden property is set to false, it's displayed when the conditions no longer apply.

To determine if the element is actually visible, use the isVisible property.

To set the hidden property on an element, use the element's hide() or show() functions.

If you select Hidden on load in the element's Properties panel in the Editor, the hidden property is set to true when the page loads.

Type

Boolean

Examples

Get an element's hidden status

bGV0IGlzSGlkZGVuID0gJHcoIiNteUVsZW1lbnQiKS5oaWRkZW47ICAvLyBmYWxzZQo=
let isHidden = $w("#myElement").hidden;  // false

Toggle an element's hidden state

aWYoICR3KCIjbXlFbGVtZW50IikuaGlkZGVuICkgewogICR3KCIjbXlFbGVtZW50Iikuc2hvdygpOwp9CmVsc2UgewogICR3KCIjbXlFbGVtZW50IikuaGlkZSgpOwp9Cg==
if( $w("#myElement").hidden ) {
  $w("#myElement").show();
}
else {
  $w("#myElement").hide();
}

Default Value

false

Mixed In From

$w.HiddenCollapsedMixin

See Also

hide( ), show( ), collapse( ), expand( ), collapsed, rendered

id

id

Gets the elements's ID.

Syntax

get id(): string

Description

The ID is the element's unique identifier. It is used when selecting elements using the $w() function.

An element's id is set in the Editor using the Properties panel.

Type

String

Examples

Get the ID

bGV0IG15SWQgPSAkdygiI215RWxlbWVudCIpLmlkOyAvLyAibXlFbGVtZW50Igo=
let myId = $w("#myElement").id; // "myElement"

Mixed In From

$w.Element

isVisible

isVisible

Indicates if the element is actually visible.

Syntax

get isVisible(): boolean

Description

If isVisible is true, the element is displayed on the page.

If isVisible is false, the element is not displayed on the page.

The value of the isVisible property is calculated based on the hidden, collapsed, and rendered properties of the element and all of its ancestors. It is true only if the conditions exist in the element's property values and the property values of its ancestors such that the element is actually displayed on the page.

Type

Boolean

Examples

Get whether an element is visible

bGV0IGlzVmlzaWJsZSA9ICR3KCIjbXlFbGVtZW50IikuaXNWaXNpYmxlOyAgLy8gdHJ1ZQo=
let isVisible = $w("#myElement").isVisible;  // true

Default Value

true

Mixed In From

$w.HiddenCollapsedMixin

See Also

hidden, collapsed, rendered

parent

parent

Gets the element's parent element.

Syntax

get parent(): Node

Description

Some elements can contain other elements. This occurs when you drag an element onto a container element. The container is the parent of all the elements it contains.

Page, Header, and Footer are top-level elements and have no parent.

Type

Node

Examples

Get the parent element and the parent's ID

bGV0IHBhcmVudEVsZW1lbnQgPSAkdygiI215RWxlbWVudCIpLnBhcmVudDsKCmxldCBwYXJlbnRJZCA9IHBhcmVudEVsZW1lbnQuaWQ7IC8vICJwYWdlMSIK
let parentElement = $w("#myElement").parent;

let parentId = parentElement.id; // "page1"

Default Value

null

Mixed In From

$w.Element

See Also

children

rendered

rendered

Indicates if an element is currently displayed.

Syntax

get rendered(): boolean

Description

If rendered is true, the element is in the current DOM structure and can be used.

If rendered is false the element is not in the current DOM structure.

Some reasons the element might not be in the DOM inclue:

  • It is in a slide which is not currently showing.
  • It is in a mode which is not currently active. For example, it is in the hover mode of a hover box.

Type

Boolean

Default Value

false

Mixed In From

$w.Element

See Also

collapsed, hidden, isVisible

type

type

Gets the element's type.

Syntax

get type(): string

Type

String

Examples

Get the element's type

bGV0IG15VHlwZSA9ICR3KCIjbXlFbGVtZW50IikudHlwZTsgLy8gIiR3LlR5cGUiCg==
let myType = $w("#myElement").type; // "$w.Type"

Mixed In From

$w.Element

collapse( )

collapse( )

Collapses the element and sets its collapsed property to true.

function collapse(): Promise<void>

Description

The collapse() function returns a Promise that is resolved when the element's collapsed property has been set to true.

To learn about the behavior of a collapsed element, see the collapsed property.

You can also collapse an element when the page loads by using the Properties panel in the Editor.

Return Value

Returns a Promise

On fulfillment void When the element's collapsed property has been set to true.

Examples

Collapse an element

JHcoIiNteUVsZW1lbnQiKS5jb2xsYXBzZSgpOwo=
$w("#myElement").collapse();

Collapse an element and log a message when done

JHcoIiNteUVsZW1lbnQiKS5jb2xsYXBzZSgpCiAgLnRoZW4oICgpID0+IHsKICAgIGNvbnNvbGUubG9nKCJEb25lIHdpdGggY29sbGFwc2UiKTsKICB9ICk7Cg==
$w("#myElement").collapse()
  .then( () => {
    console.log("Done with collapse");
  } );

Toggle an element's collapsed state

aWYoICR3KCIjbXlFbGVtZW50IikuY29sbGFwc2VkICkgewogICR3KCIjbXlFbGVtZW50IikuZXhwYW5kKCk7Cn0KZWxzZSB7CiAgJHcoIiNteUVsZW1lbnQiKS5jb2xsYXBzZSgpOwp9Cg==
if( $w("#myElement").collapsed ) {
  $w("#myElement").expand();
}
else {
  $w("#myElement").collapse();
}

Mixed In From

$w.HiddenCollapsedMixin

See Also

expand( ), collapsed, hide( )

expand( )

expand( )

Expands the element and sets its collapsed property to false.

function expand(): Promise<void>

Description

The expand() function returns a Promise that is resolved when the element's collapsed property has been set to false.

To learn about the behavior of an expanded element, see the collapsed property.

Return Value

Returns a Promise

On fulfillment void When the element's collapsed property has been set to false.

Examples

Expand an element

JHcoIiNteUVsZW1lbnQiKS5leHBhbmQoKTsK
$w("#myElement").expand();

Expand an element and log a message when done

JHcoIiNteUVsZW1lbnQiKS5leHBhbmQoKQogIC50aGVuKCAoKSA9PiB7CiAgICBjb25zb2xlLmxvZygiRG9uZSB3aXRoIGV4cGFuZCIpOwogIH0gKTsK
$w("#myElement").expand()
  .then( () => {
    console.log("Done with expand");
  } );

Toggle an element's collapsed state

aWYoICR3KCIjbXlFbGVtZW50IikuY29sbGFwc2VkICkgewogICR3KCIjbXlFbGVtZW50IikuZXhwYW5kKCk7Cn0KZWxzZSB7CiAgJHcoIiNteUVsZW1lbnQiKS5jb2xsYXBzZSgpOwp9Cg==
if( $w("#myElement").collapsed ) {
  $w("#myElement").expand();
}
else {
  $w("#myElement").collapse();
}

Mixed In From

$w.HiddenCollapsedMixin

See Also

expand( ), collapsed, show( )

getProduct( )

getProduct( )

Gets the all the information associated with the currect product.

function getProduct(): Promise<StoreProduct>

Description

The getProduct() function returns a Promise that is resolved when all of the information about the product shown on the ProductPage is retrieved.

Return Value

Returns a Promise

On fulfillment StoreProduct When the information associated with the currect product has been retrieved.

Examples

Get the current product's information

JHcoJyNteVByb2R1Y3RQYWdlJykuZ2V0UHJvZHVjdCgpCiAgLnRoZW4oIChwcm9kdWN0KSA9PiB7CiAgICBsZXQgcHJvZHVjdE5hbWUgPSBwcm9kdWN0Lm5hbWU7CiAgICBsZXQgcHJvZHVjdERlc2NyaXB0aW9uID0gcHJvZHVjdC5kZXNjcmlwdGlvbjsKICAgIC8vIHNlZSBleGFtcGxlIHByb2R1Y3Qgb2JqZWN0IGJlbG93CiAgfSApCiAgLmNhdGNoKCAoZXJyb3IpID0+IHsKICAgIGNvbnNvbGUubG9nKGVycm9yKTsKICB9ICk7CgovKgogKiBFeGFtcGxlIHByb2R1Y3Qgb2JqZWN0OgogKgogKiB7CiAqICAgIl9pZCI6ICAgICAgICAgICIzZmI2YTNjOC05ODhiLTg3NTUtMDRiZC01YzU5YWUwYjE4ZWEiLAogKiAgICJuYW1lIjogICAgICAgICAiUHJvZHVjdCBOYW1lIiwKICogICAiZGVzY3JpcHRpb24iOiAgIlByb2R1Y3QgZGVzY3JpcHRpb24iLAogKiAgICJtYWluTWVkaWEiOiAgICAiaW1hZ2U6Ly92MS9hOWZmN2IuanBnLzEwMDBfMTAwMC9maWxlLmpwZyIsCiAqICAgIm1lZGlhSXRlbXMiOiBbCiAqICAgICB7CiAqICAgICAgICJ1cmkiOiAgICAgICAgICAiYTlmZjNiXzU0MjNkODAyMjE1N2NlZjk2OGY3Yi5qcGciLAogKiAgICAgICAiZGVzY3JpcHRpb24iOiAgIk1lZGlhIGRlc2MiLAogKiAgICAgICAiYWx0IjogICAgICAgICAgIk1lZGlhIGFsdCIsCiAqICAgICAgICJ0aXRsZSI6ICAgICAgICAiTWVkaWEgdGl0bGUiLAogKiAgICAgICAid2lkdGgiOiAgICAgICAgMTAwMCwKICogICAgICAgImhlaWdodCI6ICAgICAgIDEwMDAKICogICAgIH0KICogICBdLAogKiAgICJza3UiOiAgICAgICAgICAgICAgICAgICAgICAiMzY1MjM2NDEyMzQ1MjMiLAogKiAgICJjdXJyZW5jeSI6ICAgICAgICAgICAgICAgICAiVVNEIiwKICogICAicHJpY2UiOjE1LCAgICAgICAgICAgICAgICAgImRpc2NvdW50ZWRQcmljZSI6MTUsCiAqICAgImZvcm1hdHRlZFByaWNlIjogICAgICAgICAgICIkMTUuMDAiLAogKiAgICJmb3JtYXR0ZWREaXNjb3VudGVkUHJpY2UiOiAiJDE1LjAwIiwKICogICAiaW5TdG9jayI6ICAgICAgICAgICAgICAgICAgdHJ1ZSwKICogICAiYWRkaXRpb25hbEluZm9TZWN0aW9ucyI6IFsKICogICAgIHsKICogICAgICAgInRpdGxlIjogICAgICAgICJQcm9kdWN0IGluZm8iLAogKiAgICAgICAiZGVzY3JpcHRpb24iOiAgIlByb2R1Y3QgZGV0YWlsLiIKICogICAgIH0KICogICBdLAogKiAgICJwcm9kdWN0T3B0aW9ucyI6IHsKICogICAgICJTaXplIjogewogKiAgICAgICAib3B0aW9uVHlwZSI6ICJkcm9wX2Rvd24iLAogKiAgICAgICAibmFtZSI6ICAgICAgICJTaXplIiwKICogICAgICAgImNob2ljZXMiOiBbCiAqICAgICAgICAgewogKiAgICAgICAgICAgInZhbHVlIjogICAgICAgICJTbWFsbCIsCiAqICAgICAgICAgICAiZGVzY3JpcHRpb24iOiAgIlNtYWxsIiwKICogICAgICAgICAgICJpblN0b2NrIjogICAgICB0cnVlLAogKiAgICAgICAgICAgInZpc2libGUiOiAgICAgIHRydWUKICogICAgICAgICB9LAogKiAgICAgICAgIHsKICogICAgICAgICAgICJ2YWx1ZSI6ICAgICAgICAiTGFyZ2UiLAogKiAgICAgICAgICAgImRlc2NyaXB0aW9uIjogICJMYXJnZSIsCiAqICAgICAgICAgICAiaW5TdG9jayI6ICAgICAgdHJ1ZSwKICogICAgICAgICAgICJ2aXNpYmxlIjogICAgICB0cnVlCiAqICAgICAgICAgfQogKiAgICAgICBdCiAqICAgfSwKICogICAicHJvZHVjdFBhZ2VVcmwiOiAiL3Byb2R1Y3QtcGFnZS9pLW0tYS1wcm9kdWN0LTUiLAogKiAgICJwcm9kdWN0VHlwZSI6InBoeXNpY2FsIiwKICogICAic2x1ZyI6Im15LXByb2R1Y3QiCiAqIH0KICovCg==
$w('#myProductPage').getProduct()
  .then( (product) => {
    let productName = product.name;
    let productDescription = product.description;
    // see example product object below
  } )
  .catch( (error) => {
    console.log(error);
  } );

/*
 * Example product object:
 *
 * {
 *   "_id":          "3fb6a3c8-988b-8755-04bd-5c59ae0b18ea",
 *   "name":         "Product Name",
 *   "description":  "Product description",
 *   "mainMedia":    "image://v1/a9ff7b.jpg/1000_1000/file.jpg",
 *   "mediaItems": [
 *     {
 *       "uri":          "a9ff3b_5423d8022157cef968f7b.jpg",
 *       "description":  "Media desc",
 *       "alt":          "Media alt",
 *       "title":        "Media title",
 *       "width":        1000,
 *       "height":       1000
 *     }
 *   ],
 *   "sku":                      "36523641234523",
 *   "currency":                 "USD",
 *   "price":15,                 "discountedPrice":15,
 *   "formattedPrice":           "$15.00",
 *   "formattedDiscountedPrice": "$15.00",
 *   "inStock":                  true,
 *   "additionalInfoSections": [
 *     {
 *       "title":        "Product info",
 *       "description":  "Product detail."
 *     }
 *   ],
 *   "productOptions": {
 *     "Size": {
 *       "optionType": "drop_down",
 *       "name":       "Size",
 *       "choices": [
 *         {
 *           "value":        "Small",
 *           "description":  "Small",
 *           "inStock":      true,
 *           "visible":      true
 *         },
 *         {
 *           "value":        "Large",
 *           "description":  "Large",
 *           "inStock":      true,
 *           "visible":      true
 *         }
 *       ]
 *   },
 *   "productPageUrl": "/product-page/i-m-a-product-5",
 *   "productType":"physical",
 *   "slug":"my-product"
 * }
 */
hide( )

hide( )

Hides the element and sets its hidden property to true, using an effect if specified.

function hide([effectName: Effect], [effectOptions: EffectOptions]): Promise<void>
type Effect = "arc" | "bounce" | "fade" | "flip"
| "float" | "fly" | "fold" | "glide" | "puff"
| "roll" | "slide" | "spin" | "turn" | "zoom"
type EffectOptions = ArcEffectOptions | BounceEffectOptions
| FadeEffectOptions | FlipEffectOptions | FloatEffectOptions
| FlyEffectOptions | FoldEffectOptions | GlideEffectOptions
| PuffEffectOptions | RollEffectOptions | SlideEffectOptions
| SpinEffectOptions | TurnEffectOptions | ZoomEffectOptions

Description

The hide() function hides the element and returns a Promise that is resolved when the effect is complete and the element's hidden property has been set to true.

To learn about the behavior of a hidden element, see the hidden property.

You can optionally apply an effect when hiding the element by providing an effectName value. You can also customize the effect by providing the optional effectOptions object.

Effects:

You can also hide an element when the page loads by using the Properties panel in the Editor.

Parameters

effectName (optional) String The name of the effect to play when hiding the item.
effectOptions (optional) ArcEffectOptions |
BounceEffectOptions |
FadeEffectOptions |
FlipEffectOptions |
FloatEffectOptions |
FlyEffectOptions |
FoldEffectOptions |
GlideEffectOptions |
PuffEffectOptions |
RollEffectOptions |
SlideEffectOptions |
SpinEffectOptions |
TurnEffectOptions |
ZoomEffectOptions
The effect's options.

Return Value

Returns a Promise

On fulfillment void When the effect is complete and the element's hidden property has been set to true.

Examples

Hide an element with no effect

JHcoIiNteUVsZW1lbnQiKS5oaWRlKCk7Cg==
$w("#myElement").hide();

Hide an element with the "fade" effect

JHcoIiNteUVsZW1lbnQiKS5oaWRlKCJmYWRlIik7Cg==
$w("#myElement").hide("fade");

Hide an element with an effect and log message when the effect is done

bGV0IGZhZGVPcHRpb25zID0gewogICJkdXJhdGlvbiI6ICAgMjAwMCwKICAiZGVsYXkiOiAgICAgIDEwMDAKfTsKCiR3KCIjbXlFbGVtZW50IikuaGlkZSgiZmFkZSIsIGZhZGVPcHRpb25zKTsK
let fadeOptions = {
  "duration":   2000,
  "delay":      1000
};

$w("#myElement").hide("fade", fadeOptions);

Hide an element with an effect and log message when the effect is done

JHcoIiNteUVsZW1lbnQiKS5oaWRlKCJmYWRlIikKICAudGhlbiggKCApID0+IHsKICAgIGNvbnNvbGUubG9nKCJEb25lIHdpdGggZmFkZSIpOwp9ICk7Cg==
$w("#myElement").hide("fade")
  .then( ( ) => {
    console.log("Done with fade");
} );

Toggle an element's hidden state

aWYoICR3KCIjbXlFbGVtZW50IikuaGlkZGVuICkgewogICR3KCIjbXlFbGVtZW50Iikuc2hvdygpOwp9CmVsc2UgewogICR3KCIjbXlFbGVtZW50IikuaGlkZSgpOwp9Cg==
if( $w("#myElement").hidden ) {
  $w("#myElement").show();
}
else {
  $w("#myElement").hide();
}

Mixed In From

$w.HiddenCollapsedMixin

See Also

show( ), hidden, collapse( )

onMouseIn( )

onMouseIn( )

Adds an event handler that runs when the mouse pointer is moved onto the element.

function onMouseIn(handler: MouseEventHandler): Element
callback MouseEventHandler(event: MouseEvent, $w: Function): void

Parameters

handler function(event, $w) The name of the function or the function expression to run when the mouse pointer is moved onto the element.
event MouseEvent The mouse event that occurred.
$w $w A selector function. The $w function enables event handlers to work with elements in repeaters and in the global scope.

Return Value

Element The element to which the event handler was added.

Examples

Get the mouse event info when the mouse enters an element

JHcoIiNteUVsZW1lbnQiKS5vbk1vdXNlSW4oIChldmVudCwgJHcpID0+IHsKICBsZXQgY2xpZW50WCA9IGV2ZW50LmNsaWVudFg7ICAvLyAzNjIKICBsZXQgY2xpZW50WSA9IGV2ZW50LmNsaWVudFk7ICAvLyAyNDQKICBsZXQgb2Zmc2V0WCA9IGV2ZW50Lm9mZnNldFg7ICAvLyAxMAogIGxldCBvZmZzZXRZID0gZXZlbnQub2Zmc2V0WTsgIC8vIDEyCiAgbGV0IHBhZ2VYID0gZXZlbnQucGFnZVg7ICAgICAgLy8gMzYyCiAgbGV0IHBhZ2VZID0gZXZlbnQucGFnZVk7ICAgICAgLy8gMzc2CiAgbGV0IHNjcmVlblggPSBldmVudC5zY3JlZW5YOyAgLy8gMzg5NwogIGxldCBzY3JlZW5ZID0gZXZlbnQuc2NyZWVuWTsgIC8vIDM2Mgp9ICk7Cg==
$w("#myElement").onMouseIn( (event, $w) => {
  let clientX = event.clientX;  // 362
  let clientY = event.clientY;  // 244
  let offsetX = event.offsetX;  // 10
  let offsetY = event.offsetY;  // 12
  let pageX = event.pageX;      // 362
  let pageY = event.pageY;      // 376
  let screenX = event.screenX;  // 3897
  let screenY = event.screenY;  // 362
} );

Mixed In From

$w.Element

onMouseOut( )

onMouseOut( )

Adds an event handler that runs when the mouse pointer is moved off of the element.

function onMouseOut(handler: MouseEventHandler): Element
callback MouseEventHandler(event: MouseEvent, $w: Function): void

Parameters

handler function(event, $w) The name of the function or the function expression to run when the mouse pointer is moved off of the element.
event MouseEvent The mouse event that occurred.
$w $w A selector function. The $w function enables event handlers to work with elements in repeaters and in the global scope.

Return Value

Element The element to which the event handler was added.

Examples

Get the mouse event info when the mouse exits an element

JHcoIiNteUVsZW1lbnQiKS5vbk1vdXNlT3V0KCAoZXZlbnQsICR3KSA9PiB7CiAgbGV0IGNsaWVudFggPSBldmVudC5jbGllbnRYOyAgLy8gMzYyCiAgbGV0IGNsaWVudFkgPSBldmVudC5jbGllbnRZOyAgLy8gMjQ0CiAgbGV0IG9mZnNldFggPSBldmVudC5vZmZzZXRYOyAgLy8gMTAKICBsZXQgb2Zmc2V0WSA9IGV2ZW50Lm9mZnNldFk7ICAvLyAxMgogIGxldCBwYWdlWCA9IGV2ZW50LnBhZ2VYOyAgICAgIC8vIDM2MgogIGxldCBwYWdlWSA9IGV2ZW50LnBhZ2VZOyAgICAgIC8vIDM3NgogIGxldCBzY3JlZW5YID0gZXZlbnQuc2NyZWVuWDsgIC8vIDM4OTcKICBsZXQgc2NyZWVuWSA9IGV2ZW50LnNjcmVlblk7ICAvLyAzNjIKfSApOwo=
$w("#myElement").onMouseOut( (event, $w) => {
  let clientX = event.clientX;  // 362
  let clientY = event.clientY;  // 244
  let offsetX = event.offsetX;  // 10
  let offsetY = event.offsetY;  // 12
  let pageX = event.pageX;      // 362
  let pageY = event.pageY;      // 376
  let screenX = event.screenX;  // 3897
  let screenY = event.screenY;  // 362
} );

Mixed In From

$w.Element

onViewportEnter( )

onViewportEnter( )

Adds an event handler that runs when an element is displayed in the viewable part of the current window.

function onViewportEnter(handler: EventHandler): Element
callback EventHandler(event: Event, $w: Function): void

Description

An element enters the viewport when the page is scrolled to show any part of the element. An element also enters the viewport if it was hidden or collapsed and is then shown or expanded in the viewable part of the current window.

Parameters

handler function(event, $w) The name of the function or the function expression to run when the element enters the viewport.
event Event The event that occurred.
$w $w A selector function. The $w function enables event handlers to work with elements in repeaters and in the global scope.

Return Value

Element The element on which the event is now registered.

Examples

Get the ID of the element that has entered the viewport

JHcoIiNteUVsZW1lbnQiKS5vblZpZXdwb3J0RW50ZXIoIChldmVudCwgJHcpID0+IHsKICBsZXQgdGFyZ2V0SWQgPSBldmVudC50YXJnZXQuaWQ7IC8vICJteUVsZW1lbnQiCn0pOwo=
$w("#myElement").onViewportEnter( (event, $w) => {
  let targetId = event.target.id; // "myElement"
});

Mixed In From

$w.Element

See Also

onViewportLeave( )

onViewportLeave( )

onViewportLeave( )

Adds an event handler that runs when an element is no longer displayed in the viewable part of the current window.

function onViewportLeave(handler: EventHandler): Element
callback EventHandler(event: Event, $w: Function): void

Description

An element leaves the viewport when the page is scrolled so that the elements is completely out of view. An element also leaves the viewport if it was shown or expanded and is then hidden or collapsed from the viewable part of the current window.

Parameters

handler function(event, $w) The name of the function or the function expression to run when the element leaves the viewport.
event Event The event that occurred.
$w $w A selector function. The $w function enables event handlers to work with elements in repeaters and in the global scope.

Return Value

Element The element on which the event is now registered.

Examples

Get the ID of the element that has entered the viewport

JHcoIiNteUVsZW1lbnQiKS5vblZpZXdwb3J0TGVhdmUoIChldmVudCwgJHcpID0+IHsKICBsZXQgdGFyZ2V0SWQgPSBldmVudC50YXJnZXQuaWQ7IC8vICJteUVsZW1lbnQiCn0pOwo=
$w("#myElement").onViewportLeave( (event, $w) => {
  let targetId = event.target.id; // "myElement"
});

Mixed In From

$w.Element

See Also

ViewportMixin-onViewportEnter( )

scrollTo( )

scrollTo( )

Scrolls the page to the element using an animation.

function scrollTo(): Promise<void>

Description

The scrollTo() function returns a Promise that is resolved when the animated scroll is complete and the element is now in view.

To scroll to a specific location on the page, see the wix-window scrollTo() function.

Calling the scrollTo() function on an element in a repeated item that is selected from the global scope causes an error.

Return Value

Returns a Promise

On fulfillment void When the scroll is complete.

Examples

Scroll the page to an element

JHcoIiNteUVsZW1lbnQiKS5zY3JvbGxUbygpOwo=
$w("#myElement").scrollTo();

Scroll the page to an element and log message when done

JHcoIiNteUVsZW1lbnQiKS5zY3JvbGxUbygpCiAgLnRoZW4oICggKSA9PiB7CiAgICBjb25zb2xlLmxvZygiRG9uZSB3aXRoIHNjcm9sbCIpOwp9ICk7Cg==
$w("#myElement").scrollTo()
  .then( ( ) => {
    console.log("Done with scroll");
} );

Mixed In From

$w.Element

show( )

show( )

Shows the element and sets its hidden property to false, using an effect if specified.

function show([effectName: Effect], [effectOptions: EffectOptions]): Promise<void>
type Effect = "arc" | "bounce" | "fade" | "flip"
| "float" | "fly" | "fold" | "glide" | "puff"
| "roll" | "slide" | "spin" | "turn" | "zoom"
type EffectOptions = ArcEffectOptions | BounceEffectOptions
| FadeEffectOptions | FlipEffectOptions | FloatEffectOptions
| FlyEffectOptions | FoldEffectOptions | GlideEffectOptions
| PuffEffectOptions | RollEffectOptions | SlideEffectOptions
| SpinEffectOptions | TurnEffectOptions | ZoomEffectOptions

Description

The show() function shows the element and returns a Promise that is resolved when the effect is complete and the element's hidden property has been set to false.

You can optionally apply an effect when showing the element by providing an effectName value. You can also customize the effect by providing the optional effectOptions object.

Effects:

Parameters

effectName (optional) String The name of the effect to play when showing the item.
effectOptions (optional) ArcEffectOptions |
BounceEffectOptions |
FadeEffectOptions |
FlipEffectOptions |
FloatEffectOptions |
FlyEffectOptions |
FoldEffectOptions |
GlideEffectOptions |
PuffEffectOptions |
RollEffectOptions |
SlideEffectOptions |
SpinEffectOptions |
TurnEffectOptions |
ZoomEffectOptions
The effect's options.

Return Value

Returns a Promise

On fulfillment void When the effect is complete and the element's hidden property has been set to false.

Examples

Show an element with no effect

JHcoIiNteUVsZW1lbnQiKS5zaG93KCk7Cg==
$w("#myElement").show();

Show an element with the "fade" effect

JHcoIiNteUVsZW1lbnQiKS5zaG93KCJmYWRlIik7Cg==
$w("#myElement").show("fade");

Show an element with the "fade" effect and custom options

bGV0IGZhZGVPcHRpb25zID0gewogICJkdXJhdGlvbiI6ICAgMjAwMCwKICAiZGVsYXkiOiAgICAgIDEwMDAKfTsKCiR3KCIjbXlFbGVtZW50Iikuc2hvdygiZmFkZSIsIGZhZGVPcHRpb25zKTsK
let fadeOptions = {
  "duration":   2000,
  "delay":      1000
};

$w("#myElement").show("fade", fadeOptions);

Show an element with an effect and log message when the effect is done

JHcoIiNteUVsZW1lbnQiKS5zaG93KCJmYWRlIikKICAudGhlbiggKCApID0+IHsKICAgIGNvbnNvbGUubG9nKCJEb25lIHdpdGggZmFkZSIpOwogIH0gKTsK
$w("#myElement").show("fade")
  .then( ( ) => {
    console.log("Done with fade");
  } );

Toggle an element's hidden state

aWYoICR3KCIjbXlFbGVtZW50IikuaGlkZGVuICkgewogICR3KCIjbXlFbGVtZW50Iikuc2hvdygpOwp9CmVsc2UgewogICR3KCIjbXlFbGVtZW50IikuaGlkZSgpOwp9Cg==
if( $w("#myElement").hidden ) {
  $w("#myElement").show();
}
else {
  $w("#myElement").hide();
}

Mixed In From

$w.HiddenCollapsedMixin

See Also

hide( ), hidden, expand( )

StoreProduct

StoreProduct

An object representing a product in a store.

Type

Object

Properties

_id String Product ID.
name String Product name.
description String Product description.
mainMedia String Main product media item (image or video thumbnail) URL.
mediaItems ImageItem[ ] |
VideoItem[ ]
List of product media items.
sku String Product stock keeping unit value.
ribbons StoreProductRibbon[ ] List of product ribbons.
currency String Product currency.
price Number Product price.
discountedPrice Number Discounted product price.
formattedPrice String Product price formatted with the currency.
formattedDiscountedPrice String Discounted product price formatted with the currency.
trackInventory Boolean Indicates whether inventory is tracked for the product.
inStock Boolean Indicates whether the product is in stock.
quantityInStock Number Number of units currently in stock.
additionalInfoSections StoreProductAdditionalInfoSection[ ] Additional product information sections.
productOptions StoreProductOptions All the available options for a store product.
productPageUrl String Product page relative URL.
manageVariants Boolean Indicates whether product variants are managed.
customTextField StoreProductCustomTextFields[ ] List of product customization fields.
productType String Product type. Either "physical" or "digital".
slug String Product slug.
weight String Product weight.

Examples

Get the current product's information

JHcoJyNteVByb2R1Y3RQYWdlJykuZ2V0UHJvZHVjdCgpCiAgLnRoZW4oIChwcm9kdWN0KSA9PiB7CiAgICBsZXQgcHJvZHVjdE5hbWUgPSBwcm9kdWN0Lm5hbWU7CiAgICBsZXQgcHJvZHVjdERlc2NyaXB0aW9uID0gcHJvZHVjdC5kZXNjcmlwdGlvbjsKICAgIC8vIHNlZSBleGFtcGxlIHByb2R1Y3Qgb2JqZWN0IGJlbG93CiAgfSApCiAgLmNhdGNoKCAoZXJyb3IpID0+IHsKICAgIGNvbnNvbGUubG9nKGVycm9yKTsKICB9ICk7CgovKgogKiBFeGFtcGxlIHByb2R1Y3Qgb2JqZWN0OgogKgogKiB7CiAqICAgIl9pZCI6ICAgICAgICAgICIzZmI2YTNjOC05ODhiLTg3NTUtMDRiZC01YzU5YWUwYjE4ZWEiLAogKiAgICJuYW1lIjogICAgICAgICAiUHJvZHVjdCBOYW1lIiwKICogICAiZGVzY3JpcHRpb24iOiAgIlByb2R1Y3QgZGVzY3JpcHRpb24iLAogKiAgICJtYWluTWVkaWEiOiAgICAiaW1hZ2U6Ly92MS9hOWZmN2IuanBnLzEwMDBfMTAwMC9maWxlLmpwZyIsCiAqICAgIm1lZGlhSXRlbXMiOiBbCiAqICAgICB7CiAqICAgICAgICJ1cmkiOiAgICAgICAgICAiYTlmZjNiXzU0MjNkODAyMjE1N2NlZjk2OGY3Yi5qcGciLAogKiAgICAgICAiZGVzY3JpcHRpb24iOiAgIk1lZGlhIGRlc2MiLAogKiAgICAgICAiYWx0IjogICAgICAgICAgIk1lZGlhIGFsdCIsCiAqICAgICAgICJ0aXRsZSI6ICAgICAgICAiTWVkaWEgdGl0bGUiLAogKiAgICAgICAid2lkdGgiOiAgICAgICAgMTAwMCwKICogICAgICAgImhlaWdodCI6ICAgICAgIDEwMDAKICogICAgIH0KICogICBdLAogKiAgICJza3UiOiAgICAgICAgICAgICAgICAgICAgICAiMzY1MjM2NDEyMzQ1MjMiLAogKiAgICJjdXJyZW5jeSI6ICAgICAgICAgICAgICAgICAiVVNEIiwKICogICAicHJpY2UiOjE1LCAgICAgICAgICAgICAgICAgImRpc2NvdW50ZWRQcmljZSI6MTUsCiAqICAgImZvcm1hdHRlZFByaWNlIjogICAgICAgICAgICIkMTUuMDAiLAogKiAgICJmb3JtYXR0ZWREaXNjb3VudGVkUHJpY2UiOiAiJDE1LjAwIiwKICogICAiaW5TdG9jayI6ICAgICAgICAgICAgICAgICAgdHJ1ZSwKICogICAiYWRkaXRpb25hbEluZm9TZWN0aW9ucyI6IFsKICogICAgIHsKICogICAgICAgInRpdGxlIjogICAgICAgICJQcm9kdWN0IGluZm8iLAogKiAgICAgICAiZGVzY3JpcHRpb24iOiAgIlByb2R1Y3QgZGV0YWlsLiIKICogICAgIH0KICogICBdLAogKiAgICJwcm9kdWN0T3B0aW9ucyI6IHsKICogICAgICJTaXplIjogewogKiAgICAgICAib3B0aW9uVHlwZSI6ICJkcm9wX2Rvd24iLAogKiAgICAgICAibmFtZSI6ICAgICAgICJTaXplIiwKICogICAgICAgImNob2ljZXMiOiBbCiAqICAgICAgICAgewogKiAgICAgICAgICAgInZhbHVlIjogICAgICAgICJTbWFsbCIsCiAqICAgICAgICAgICAiZGVzY3JpcHRpb24iOiAgIlNtYWxsIiwKICogICAgICAgICAgICJpblN0b2NrIjogICAgICB0cnVlLAogKiAgICAgICAgICAgInZpc2libGUiOiAgICAgIHRydWUKICogICAgICAgICB9LAogKiAgICAgICAgIHsKICogICAgICAgICAgICJ2YWx1ZSI6ICAgICAgICAiTGFyZ2UiLAogKiAgICAgICAgICAgImRlc2NyaXB0aW9uIjogICJMYXJnZSIsCiAqICAgICAgICAgICAiaW5TdG9jayI6ICAgICAgdHJ1ZSwKICogICAgICAgICAgICJ2aXNpYmxlIjogICAgICB0cnVlCiAqICAgICAgICAgfQogKiAgICAgICBdCiAqICAgfSwKICogICAicHJvZHVjdFBhZ2VVcmwiOiAiL3Byb2R1Y3QtcGFnZS9pLW0tYS1wcm9kdWN0LTUiLAogKiAgICJwcm9kdWN0VHlwZSI6InBoeXNpY2FsIiwKICogICAic2x1ZyI6Im15LXByb2R1Y3QiCiAqIH0KICovCg==
$w('#myProductPage').getProduct()
  .then( (product) => {
    let productName = product.name;
    let productDescription = product.description;
    // see example product object below
  } )
  .catch( (error) => {
    console.log(error);
  } );

/*
 * Example product object:
 *
 * {
 *   "_id":          "3fb6a3c8-988b-8755-04bd-5c59ae0b18ea",
 *   "name":         "Product Name",
 *   "description":  "Product description",
 *   "mainMedia":    "image://v1/a9ff7b.jpg/1000_1000/file.jpg",
 *   "mediaItems": [
 *     {
 *       "uri":          "a9ff3b_5423d8022157cef968f7b.jpg",
 *       "description":  "Media desc",
 *       "alt":          "Media alt",
 *       "title":        "Media title",
 *       "width":        1000,
 *       "height":       1000
 *     }
 *   ],
 *   "sku":                      "36523641234523",
 *   "currency":                 "USD",
 *   "price":15,                 "discountedPrice":15,
 *   "formattedPrice":           "$15.00",
 *   "formattedDiscountedPrice": "$15.00",
 *   "inStock":                  true,
 *   "additionalInfoSections": [
 *     {
 *       "title":        "Product info",
 *       "description":  "Product detail."
 *     }
 *   ],
 *   "productOptions": {
 *     "Size": {
 *       "optionType": "drop_down",
 *       "name":       "Size",
 *       "choices": [
 *         {
 *           "value":        "Small",
 *           "description":  "Small",
 *           "inStock":      true,
 *           "visible":      true
 *         },
 *         {
 *           "value":        "Large",
 *           "description":  "Large",
 *           "inStock":      true,
 *           "visible":      true
 *         }
 *       ]
 *   },
 *   "productPageUrl": "/product-page/i-m-a-product-5",
 *   "productType":"physical",
 *   "slug":"my-product"
 * }
 */

See Also

getProduct( )

StoreProductAdditionalInfoSection

StoreProductAdditionalInfoSection

An object representing an additional info section for a store product.

Type

Object

Properties

title String Section title.
description String Section description.

See Also

getProduct( ), StoreProduct

StoreProductCustomTextFields

StoreProductCustomTextFields

An object representing a custom text field for a store product.

Type

Object

Properties

title String Product customization field title.
maxLength String Maximum length of product customization field in characters.

See Also

getProduct( ), StoreProduct

StoreProductOption

StoreProductOption

An object representing an option for a store product.

Properties

optionType String Option type. Either "color" or "drop_down".
name String Option name.
choices StoreProductOptionsChoice[ ] Option choices.

See Also

getProduct( ), StoreProductOptions

StoreProductOptions

StoreProductOptions

An object representing all the available options for a store product.

Properties

optionKey StoreProductOption Name of the option. This key name is dependent on the options added to the product. For example, if a product has a size option, this key will be something like "Size".

See Also

getProduct( ), StoreProduct

StoreProductOptionsChoice

StoreProductOptionsChoice

An object representing an additional info section for a store product.

Type

Object

Properties

value Number Choice value.
description Number Choice description.
media StoreProductOptionsChoiceMedia Choice media.
inStock Boolean Indicates whether the product with this choice is in stock.
visible Boolean Indicates whether the product with this option is visible.

See Also

getProduct( ), StoreProductOption

StoreProductOptionsChoiceMedia

StoreProductOptionsChoiceMedia

An object representing the choice media

Type

Object

Properties

mainMedia String Main choice media item (image or video thumbnail) URL.
mediaItems ImageItem[ ] |
VideoItem[ ]
List of choice media items.

See Also

getProduct( ), StoreProductOptionsChoice

StoreProductRibbon

StoreProductRibbon

An object representing a ribbon for a store product.

Type

Object

Properties

text String Ribbon text.

See Also

getProduct( ), StoreProduct