StockDownloader - Download data about variants Print

  • 0

In-class Shop. Class that takes a product variant data and displays them on the card. This is the only under-class that has multiple instances of [for each variant is created individually], and is not assigned at the start of the Shop! For her the call corresponds to the stockHandler and usually there is no need to put extra start up conditions:

    Shop.
    stockDownloader.condition
    =
    Function.from(true);

The parameters in the HTML

  • Shop.values.OptionImgWidth (int) - the size of the product pictures
  • Shop.values.OptionImgHeight (int) - jw.
  • Shop.values.optionCurrentStock (int) - By default, the ID of the selected Variant

The parameters in the JS

Parameters Shop.stockDownloader.options :

  • Getstockurl (string) - the address for the data collected must include three strings:
    • {sid} - replaced with the desired id Variant
    • {imgwidth} - the width of the product pictures
    • {imgheight} - the amount of product images
  • Selectors (object) - selector to all data of the variant, no default
    • stockid - <input name=„stock_id”> (usually type=„hidden”), that passes the time with a button „Add to cart”, ID variant
    • productimg - <img> with a photo of the product
    • ddavailability - element for the description of the availability of
    • dddelivery - element for the description of the delivery times
    • dtdelivery - element preceding the dddelivery, usually with the word „shipping” - in the absence of product shipping both are hidden (class none)
    • price - the price of a product
    • nettoprice - net price
    • addtofav - <a>, whose href is set to add a Variant to the vault
    • basketform - Add a form to your shopping cart, hidden (class none), When you can't buy a Variant
    • unit - product unit <input> the number of form (shopping cart)
    • smallgallery - <img> a small gallery of images as the current selected photo is the variant

The Phrase:

  • Shop.lang.common.product_stock_download_error

Auxiliary functions

Functions are placed outside the instances of the class in order to make it easier to modify their own behaviour code.

get()

        Shop.stockDownloader.get(shop_instance,
        sid
        )
    

The function called by the stockHandler After selecting option. Takes an instance of a class in the Shop and the ID of the Variant. Checks to see if the information were already downloaded [the array Shop.stockDownloader.downloaded]. If so, it is called on them display(). If not, a new instance is created that retrieves and populates the data on the page.


Was this answer helpful?

« Back