Documentation

Shop extends ShopLibrary
in package

Shop

Tags
internal

Extract code from this class and move it to other classes: Customer, Product, Order, ...

internal

It doesn't really make sense to extend ShopLibrary. Instead, dissolve ShopLibrary into classes like Shop, Zones, Country, Payment, etc.

author

Reto Kohli reto.kohli@comvation.com

author

Ivan Schmid ivan.schmid@comvation.com

access

public

subpackage

module_shop

version
3.0.0

Table of Contents

Constants

block_shop_products  = 'block_shop_products'
Name of the template block for Products
IMAGE_PARSE_BEHAVIOUR_FILLING  = 'filling'
If set through setting option image_parse_behaviour, then the related image placeholders of a product will be parsed with any set images.
IMAGE_PARSE_BEHAVIOUR_FIXED  = 'fixed'
If set through setting option image_parse_behaviour, then the related image placeholders of a product will be parsed excatly as set.
noPictureName  = 'no_picture.gif'
numof_remember_visited_products  = 4
Count of products last visited by the visitor
PAYMENT_RESULT_CANCEL  = 2
PAYMENT_RESULT_FAIL  = 0
PAYMENT_RESULT_SUCCESS  = 1
PAYMENT_RESULT_SUCCESS_SILENT  = -1
Payment result constant values
REGISTER_MANDATORY  = 'mandatory'
REGISTER_NONE  = 'none'
REGISTER_OPTIONAL  = 'optional'
thumbnailSuffix  = '.thumb'

Properties

$defaultImageSize  : array<string|int, mixed>
Holds the result of getimagesize() on {@see static::$defaultImage}.
$errorFields  : array<string|int, mixed>
List of field names with failed validation
$hasSession  : bool
Whether or not a session has been initialized and is being used
$mandatoryAccountFields  : array<string|int, mixed>
List of mandatory fields of account page
$pageMetaDesc  : string
Short description of current product or category.
$pageMetaImage  : string
The current page's meta image If the user is on the detail or category page, show the product or category image
$pageMetaKeys  : string
Keywords of current product, separated by comma
$pageTitle  : string
The current page's title If the user is on the detail page, show the product name
$defaultImage  : mixed
$initialized  : bool
True if the shop has been initialized
$objCustomer  : Customer
The Customer object
$objTemplate  : Sigma
The PEAR Template Sigma object
$show_currency_navbar  : bool
Currency navbar indicator
$use_js_cart  : bool
Currency navbar indicator

Methods

_calculatePaymentPrice()  : string
Returns the actual payment fee according to the payment ID and the total order price.
_calculateShipmentPrice()  : float
Returns the shipping cost converted to the active currency.
_changepass()  : bool
Change the customers' password
_getShipperMenu()  : string
Determines the shipper ID to be used, if any, stores it in $_SESSION['shop']['shipperId'], and returns the shipment dropdown menu.
_gotoLoginPage()  : mixed
_gotoPaymentPage()  : mixed
Redirects to the page following the account view
_initPaymentDetails()  : mixed
account_to_session()  : mixed
Copies data posted from the account form to the session
cart()  : mixed
Update the cart, and/or set up the view
cart_info()  : string
Returns a string containing a short Cart overview
confirm()  : bool
Generates an overview of the Order for the Customer to confirm
customer()  : mixed
destroyCart()  : mixed
Empties the shopping cart
discounts()  : bool
The view of the discounted Products only
errorHandling()  : mixed
Catch-all error handling
get_payment_menu()  : string
Determines the payment ID to be used, if any
get_products_block()  : string
DEPRECATED and OBSOLETE. Use parse_products_blocks().
getCustomOrderId()  : string
Convert the order ID and date to a custom order ID of the form "lastnameYYY", where YYY is the order ID.
getDiscountCountString()  : string
Returns a string representation of the count type discounts applicable for the given discount group ID, if any.
getNavbar()  : string
Sets up the Shop Navbar content and returns it as a string
getOrderPaymentId()  : mixed
getOrderStatus()  : mixed
getPage()  : string
Returns the Shop page for the present parameters
getPageMetaDesc()  : string
Returns the short description of the current product or the short description of the current category
getPageMetaImage()  : string
Returns the category or product image if the use is on a product's or category's page
getPageMetaKeys()  : string
Returns the keywords of the current product
getPageTitle()  : string
Returns the name of the current product
getRegisterArray()  : array<string|int, mixed>
Returns an array with all register options
getRegisterMenuoptions()  : string
Returns HTML code for the register menu options
getSubstitutionArray()  : array<string|int, mixed>
Returns an array of values to be substituted
getValidProducts()  : array<string|int, mixed>
Get the valid products
hasSession()  : bool
Returns true if the shop is using a session
init()  : mixed
Initialize
initVat()  : mixed
isInitialized()  : bool
Returns true if the shop has been initialized
login()  : bool
Show the login page
lsv_complete()  : bool
Returns true if complete LSV information is present in the session
moveImage()  : bool
Moves Product or Category images to the shop image folder if necessary and changes the given file path from absolute to relative to the shop image folder
parse_products_blocks()  : Sigma
Sets up a Product list in the given template
parseBreadcrumb()  : mixed
Parse the category/product breadcrumb
payment()  : void
Set up payment page including dropdown menus for shipment and payment options.
process()  : bool
Processes the Order
processor_name()  : mixed
processRedirect()  : string
OBSOLETE, use core_modules/login.
productOptions()  : string
Set up the HTML elements for all the Product Attributes of any Product.
registerJavascriptCode()  : mixed
Registers Javascript used by the shop
scaleImageSizeToThumbnail()  : array<string|int, mixed>
Scale the given image size down to thumbnail size
send_pricelist()  : bool
Creates and sends a Pricelist as a PDF document
sendConfirmationMail()  : bool
Send a confirmation e-mail with the order data
sendLogin()  : bool
Sends the Customer login data
setJsCart()  : void
Sets up the JavsScript cart
setNavbar()  : mixed
Sets up the Shop Navbar in the global Template only
showCategories()  : bool
Set up the subcategories block in the current shop page.
showCustomerDiscount()  : bool
Show the total pending order and the resulting discount amount.
showDiscountInfo()  : mixed
Set up the full set of discount information placeholders
showShipmentTerms()  : mixed
Set up the template block with the shipment terms and conditions
stripUniqidFromFilename()  : string
Remove the uniqid part from a file name that was added after uploading the file
success()  : mixed
The payment process has completed successfully.
update_session()  : mixed
Updates the session with all data relevant to the current order
uploadFile()  : string
Upload a file to be associated with a product in the cart
use_session()  : bool
Returns true if the Shop will require a session
verify_account()  : bool
Verifies the account data present in the session
verify_payment_details()  : mixed
verifySessionAddress()  : bool
Returns true if the cart is non-empty and all necessary address information has been stored in the session
view_account()  : mixed
view_cart()  : mixed
The cart view
view_lsv_form()  : mixed
Set up the "lsv_form" page with the user information form for LSV
view_payment()  : void
The payment and shipment selection view
view_product_overview()  : bool
Set up the shop page with products and discounts
viewpart_lsv()  : mixed
Set up the LSV partial view (internal LSV form provider)
getXmlSitemap()  : mixed
parseImagesOfProduct()  : string
preProcessImageDataOfProduct()  : array<string|int, mixed>
viewShipmentDiscount()  : mixed
Set up the Shipment discount template block
_authenticate()  : bool
Authenticate a Customer
init_session()  : void
Initialises the session with regard to the Shop
rememberVisitedProducts()  : void
Remembers the last visited Product IDs

Constants

block_shop_products

Name of the template block for Products

public mixed block_shop_products = 'block_shop_products'

If present in the main template, selected Products will be parsed. Optionally append "_category_X" with X being any Category ID.

Tags
see
ComponentController::preFinalize()
see
Shop::view_product_startpage()

IMAGE_PARSE_BEHAVIOUR_FILLING

If set through setting option image_parse_behaviour, then the related image placeholders of a product will be parsed with any set images.

public string IMAGE_PARSE_BEHAVIOUR_FILLING = 'filling'

IMAGE_PARSE_BEHAVIOUR_FIXED

If set through setting option image_parse_behaviour, then the related image placeholders of a product will be parsed excatly as set.

public string IMAGE_PARSE_BEHAVIOUR_FIXED = 'fixed'

numof_remember_visited_products

Count of products last visited by the visitor

public mixed numof_remember_visited_products = 4
Tags
see
rememberVisitedProducts()

Properties

$defaultImageSize

Holds the result of getimagesize() on {@see static::$defaultImage}.

protected static array<string|int, mixed> $defaultImageSize = []

Additionally the key 3 is set to a width&height-Html-attribute string.

$errorFields

List of field names with failed validation

protected static array<string|int, mixed> $errorFields = array()

List of field names

$hasSession

Whether or not a session has been initialized and is being used

protected static bool $hasSession = false

$mandatoryAccountFields

List of mandatory fields of account page

protected static array<string|int, mixed> $mandatoryAccountFields = array('gender', 'lastname', 'firstname', 'address', 'zip', 'city', 'phone')

"email" and "password" are not in list in order to allow the user to order without registration.

List of field names

$pageMetaDesc

Short description of current product or category.

protected static string $pageMetaDesc = ''

$pageMetaImage

The current page's meta image If the user is on the detail or category page, show the product or category image

protected static string $pageMetaImage = ''

$pageMetaKeys

Keywords of current product, separated by comma

protected static string $pageMetaKeys = ''

$pageTitle

The current page's title If the user is on the detail page, show the product name

protected static string $pageTitle = ''

$defaultImage

private static mixed $defaultImage = ''

$initialized

True if the shop has been initialized

private static bool $initialized = false

$objCustomer

The Customer object

private static Customer $objCustomer = null
Tags
access

private

static
see

lib/Customer.class.php

$objTemplate

The PEAR Template Sigma object

private static Sigma $objTemplate = null
Tags
access

private

static

$show_currency_navbar

Currency navbar indicator

private static bool $show_currency_navbar = true
Tags
access

private

$use_js_cart

Currency navbar indicator

private static bool $use_js_cart = false
Tags
access

private

Methods

_calculatePaymentPrice()

Returns the actual payment fee according to the payment ID and the total order price.

public static _calculatePaymentPrice(int $payment_id, float $totalPrice, float $shipmentPrice) : string
Parameters
$payment_id : int

The payment ID

$totalPrice : float

The total order price (of goods)

$shipmentPrice : float

The price of the shipment

Tags
internal

A lot of this belongs to the Payment class.

Return values
string

The payment fee, formatted by

_calculateShipmentPrice()

Returns the shipping cost converted to the active currency.

public static _calculateShipmentPrice(int $shipperId, float $price, int $weight) : float
Parameters
$shipperId : int

The ID of the selected shipper

$price : float

The total order value

$weight : int

The total order weight in grams

Return values
float

The shipping cost in the customers' currency

_changepass()

Change the customers' password

public static _changepass() : bool

If no customer is logged in, redirects to the login page. Returns true only after the password has been updated successfully.

Return values
bool

True on success, false otherwise

_getShipperMenu()

Determines the shipper ID to be used, if any, stores it in $_SESSION['shop']['shipperId'], and returns the shipment dropdown menu.

public static _getShipperMenu() : string

If no shipping is desired, returns an empty string.

  • If Cart::needs_shipment() evaluates to true:
    • If $_SESSION['shop']['shipperId'] is set, it is changed to the value of the shipment ID returned in $_POST['shipperId'], if the latter is set.
    • Otherwise, sets $_SESSION['shop']['shipperId'] to the default value obtained by calling Shipment::getCountriesRelatedShippingIdArray() with the country ID found in $_SESSION['shop']['countryId2'].
    • Returns the shipment dropdown menu as returned by Shipment::getShipperMenu().
  • If Cart::needs_shipment() evaluates to false, does nothing, but simply returns an empty string.
Return values
string

Shipment dropdown menu, or an empty string

_gotoLoginPage()

public static _gotoLoginPage() : mixed

_gotoPaymentPage()

Redirects to the page following the account view

public static _gotoPaymentPage() : mixed

If the cart is empty, redirects to the shop start page, or the category viewed previously, if known. If there is no payment view, redirects to the confirmation directly. Mind that there MUST be a default payment and shipment set in the latter case!

Tags
todo

Make sure there are proper payment and shipment IDs set in the session!

_initPaymentDetails()

public static _initPaymentDetails() : mixed

account_to_session()

Copies data posted from the account form to the session

public static account_to_session() : mixed

Returns immediately unless the form has been posted indeed. Considers the state of the "equal address" flag. Copies the shipment country to the billing address unless the latter is set.

cart()

Update the cart, and/or set up the view

public static cart() : mixed
Tags
see

Cart::receive_json(), Cart::add_product(), Cart::update_quantity(), _gotoLoginPage(), Cart::update(), view_cart(), Cat::send_json()

cart_info()

Returns a string containing a short Cart overview

public static cart_info() : string
Tags
static
todo

The cart info is not updated in time when the cart is destroyed and the product overview is shown again!

Return values
string

The Cart information

confirm()

Generates an overview of the Order for the Customer to confirm

public static confirm() : bool

Forward her to the processing of the Order after the button has been clicked.

Return values
bool

True on success, false otherwise

destroyCart()

Empties the shopping cart

public static destroyCart([bool $full = null ]) : mixed

Note that $full=true will not log the User off; it just flushes the static Customer object. That's somewhat experimental.

Parameters
$full : bool = null

If true, drops the entire Shop session and the Customer

Tags
static

discounts()

The view of the discounted Products only

public static discounts() : bool

Calls view_product_overview(), which in turn checks the value of the cmd request parameter, and sets up Product query parameters accordingly.

Return values
bool

True on success, false otherwise

errorHandling()

Catch-all error handling

public static errorHandling() : mixed

This should be used as a last resort only. Blames the database in a Message, and returns nothing.

get_payment_menu()

Determines the payment ID to be used, if any

public static get_payment_menu() : string

Stores it in $_SESSION['shop']['paymentId'], and returns the payment dropdown menu.

  • If there is nothing to pay (products or shipping), returns an empty string.
  • If Cart::needs_shipment() evaluates to true, and Cart::get_price() - Cart::get_discount_amount() is greater than zero:
    • If $_SESSION['shop']['paymentId'] is set, it is changed to the value of the paymentId ID returned in $_POST['paymentId'], if the latter is set.
    • Otherwise, sets $_SESSION['shop']['paymentId'] to the first value found in $arrPaymentId Payment::getCountriesRelatedPaymentIdArray() with the country ID found in $_SESSION['shop']['countryId'].
    • Returns the payment dropdown menu as returned by Payment::getPaymentMenu().
Return values
string

Payment dropdown menu, or an empty string

get_products_block()

DEPRECATED and OBSOLETE. Use parse_products_blocks().

public static get_products_block(string $content, int $category_id) : string

Sets up a Product list in the given template string with all Products taken from the Category with the given ID

Changes the $_REQUEST array temporarily and calls view_product_overview(), then restores the original request. On failure, the empty string is returned.

Parameters
$content : string

The template string

$category_id : int

The Category ID

Return values
string

The filled template string on success, the empty string otherwise

getCustomOrderId()

Convert the order ID and date to a custom order ID of the form "lastnameYYY", where YYY is the order ID.

public static getCustomOrderId(int $order_id) : string

This method may be customized to meet the needs of any shop owner. The custom order ID may be used for creating user accounts for protected downloads, for example.

Parameters
$order_id : int

The order ID

Tags
global

ADONewConnection $objDatabase Database connection object

author

Reto Kohli reto.kohli@comvation.com

Return values
string

The custom order ID

getDiscountCountString()

Returns a string representation of the count type discounts applicable for the given discount group ID, if any.

public static getDiscountCountString(int $groupCountId) : string
Parameters
$groupCountId : int

The discount group ID

Tags
global

array $_ARRAYLANG Language array

author

Reto Kohli reto.kohli@comvation.com

static
Return values
string

The string representation

getNavbar()

Sets up the Shop Navbar content and returns it as a string

public static getNavbar([type $template = NULL ][, type $use_cache = true ]) : string

Note that init() must have been called before. The content is created once and stored statically. Repeated calls will always return the same string, unless either a non-empty template is given, or $use_cache is set to false.

Parameters
$template : type = NULL

Replaces the default template ($themesPages['shopnavbar']) and sets $use_cache to false unless empty. Defaults to NULL

$use_cache : type = true

Does not use any cached content, but builds it new from scratch if false. Defaults to true.

Tags
global

array $_ARRAYLANG

global

array $themesPages

global

array $_CONFIGURATION

staticvar

array $content Caches created content

static
Return values
string

The Shop Navbar content

getOrderPaymentId()

public static getOrderPaymentId(mixed $order_id) : mixed
Parameters
$order_id : mixed

getOrderStatus()

public static getOrderStatus(mixed $order_id) : mixed
Parameters
$order_id : mixed

getPage()

Returns the Shop page for the present parameters

public static getPage(string $template) : string
Parameters
$template : string

The page template

Return values
string

The page content

getPageMetaDesc()

Returns the short description of the current product or the short description of the current category

public static getPageMetaDesc() : string
Return values
string

Short description of product or category. If no product/category is selected, then an empty string is retured.

getPageMetaImage()

Returns the category or product image if the use is on a product's or category's page

public static getPageMetaImage() : string
Return values
string

Relative image URL

getPageMetaKeys()

Returns the keywords of the current product

public static getPageMetaKeys() : string
Return values
string

Keywords of current product. If no product is selected, then an empty string is retured.

getPageTitle()

Returns the name of the current product

public static getPageTitle() : string
Return values
string

Name of current product

getRegisterArray()

Returns an array with all register options

public static getRegisterArray() : array<string|int, mixed>

Keys are the respective class constant values, and the element values are the language entries.

Tags
see
getRegisterMenuoptions()
Return values
array<string|int, mixed>

The array of register options

getRegisterMenuoptions()

Returns HTML code for the register menu options

public static getRegisterMenuoptions([string $selected = null ]) : string
Parameters
$selected : string = null

The optional selected option

Tags
see
getRegisterArray()
Return values
string

The HTML options string

getSubstitutionArray()

Returns an array of values to be substituted

public static getSubstitutionArray() : array<string|int, mixed>

Contains the following keys and values: 'SHOP_COMPANY' => The company name (from the settings) 'SHOP_HOMEPAGE' => The shop starting page URL Used primarily for all MailTemplates. Indexed by placeholder names.

Return values
array<string|int, mixed>

The substitution array

getValidProducts()

Get the valid products

public static getValidProducts([array<string|int, mixed> $productIds = array() ]) : array<string|int, mixed>
Parameters
$productIds : array<string|int, mixed> = array()
Return values
array<string|int, mixed>

array of object

hasSession()

Returns true if the shop is using a session

public static hasSession() : bool
Return values
bool

True if the shop is using a session, false otherwise

init()

Initialize

public static init() : mixed
Tags
access

public

isInitialized()

Returns true if the shop has been initialized

public static isInitialized() : bool
Return values
bool

True if initialized, false otherwise

login()

Show the login page

public static login() : bool

Redirects to the appropriate page, if necessary. Verifies and handles requests for (not) registering as a customer.

Tags
global

array $_ARRAYLANG Language array

see

_authenticate(), is_auth()

Return values
bool

True, except when redirecting

lsv_complete()

Returns true if complete LSV information is present in the session

public static lsv_complete() : bool
Return values
bool

True if LSV information is complete, false otherwise

moveImage()

Moves Product or Category images to the shop image folder if necessary and changes the given file path from absolute to relative to the shop image folder

public static moveImage(string &$imageFileSource) : bool

Images outside the shop image folder are copied there and all folder parts are stripped. Images inside the shop image folder are left where they are. The path is changed to represent the new location, relative to the shop image folder. Leading folder separators are removed. The changed path SHOULD be stored in the picture field as-is. Examples (suppose the shop image folder ASCMS_SHOP_IMAGES_WEB_PATH is 'images/shop'): /var/www/mydomain/upload/test.jpg becomes images/shop/test.jpg /var/www/mydomain/images/shop/test.jpg becomes images/shop/test.jpg /var/www/mydomain/images/shop/folder/test.jpg becomes images/shop/folder/test.jpg

Parameters
$imageFileSource : string

The absolute image path, by reference

Return values
bool

True on success, false otherwise

parse_products_blocks()

Sets up a Product list in the given template

public static parse_products_blocks(Sigma $template) : Sigma

If no Category ID is given, includes Products as indicated by the show_products_default setting. Otherwise, includes Products from the Category with the given ID. Note that you cannot use more than one such block per template! This would cause duplicate block names. Changes the $_REQUEST array temporarily and calls view_product_overview(), then restores the original request.

Parameters
$template : Sigma

The template

Return values
Sigma

The parsed template

parseBreadcrumb()

Parse the category/product breadcrumb

public static parseBreadcrumb(Sigma $objTpl[, int $selectedCatId = 0 ][, Product $product = null ]) : mixed

Parses the template block shopNavbar and shop_breadcrumb based on the currently selected category and product.

Parameters
$objTpl : Sigma

The template object to be used to parse the breadcrumb on.

$selectedCatId : int = 0

The ID of the currently selected category.

$product : Product = null

The currently selected product.

process()

Processes the Order

public static process() : bool

Verifies all data, updates and stores it in the database, and initializes payment

Return values
bool

True on successs, false otherwise

processor_name()

public static processor_name() : mixed

processRedirect()

OBSOLETE, use core_modules/login.

public static processRedirect() : string

Redirects to another page iff the Customer is logged in

Returns the redirection target when no Customer ist logged in. The default target for the redirect is the account page. Other targets may be specified using the redirect parameter.

Return values
string

The redirection target, if any

productOptions()

Set up the HTML elements for all the Product Attributes of any Product.

public static productOptions(int $product_id, string $formName[, int $cart_id = null ][, bool &$flagUpload = false ]) : string

The following types of Attributes are supported: 0 Dropdown menu, customers may select no (the default) or one option. 1 Radio buttons, customers need to select one option. 2 Checkboxes, customers may select no, one or several options. 3 Dropdown menu, customers need to select one option. 4 Optional text field 5 Mandatory text field 6 Optional file upload field 7 Mandatory file upload field Types 1 and 3 are functionally identical, they only differ by the kind of widget being used. The individual Product Attributes carry a unique ID enabling the JavaScript code contained within the Shop page to verify that all mandatory choices have been made before any Product can be added to the cart.

Parameters
$product_id : int

The Product ID

$formName : string

The name of the HTML form containing the Product and options

$cart_id : int = null

The optional cart Product ID, null if not applicable.

$flagUpload : bool = false

If a product has an upload Attribute associated with it, this parameter will be set to true

Return values
string

The string with the HTML code

registerJavascriptCode()

Registers Javascript used by the shop

public static registerJavascriptCode() : mixed

If at least one Product has an upload field Attribute associated with it, the $flagUpload parameter MUST be set to true. Note that this will force the respective product form to use mutipart/form-data encoding and disable the JSON cart for the complete page. //@param boolean $flagUpload Force the POST cart to be used if true

Tags
global

array $_ARRAYLANG Language array

global

array $_CONFIGURATION Core configuration array, see

todo

Reimplement the $flagUpload parameter

scaleImageSizeToThumbnail()

Scale the given image size down to thumbnail size

public static scaleImageSizeToThumbnail(array<string|int, mixed> &$arrSize) : array<string|int, mixed>

The target thumbnail size is taken from the configuration. The argument and returned arrays use the indices as follows: array(0 => width, 1 => height) In addition, index 3 of the array returned contains a string with the width and height attribute string, very much like the result of getimagesize(). Note that the array argument is passed by reference and its values overwritten for the indices mentioned!

Parameters
$arrSize : array<string|int, mixed>

The original image size array, by reference

Return values
array<string|int, mixed>

The scaled down (thumbnail) image size array

send_pricelist()

Creates and sends a Pricelist as a PDF document

public static send_pricelist([int $lang_id = null ]) : bool

Does not return on success, just sends the list and dies happily instead. Note that the $lang_id is ignored if it's defined for the Pricelist.

Parameters
$lang_id : int = null

The optional language ID

Return values
bool

False on failure

sendConfirmationMail()

Send a confirmation e-mail with the order data

public static sendConfirmationMail(int $order_id[, bool $create_accounts = true ]) : bool

Calls Orders::getSubstitutionArray(), which en route creates User accounts for individual electronic Products by default. Set $create_accounts to false when sending a copy.

Parameters
$order_id : int

The order ID

$create_accounts : bool = true

Create User accounts for electronic Products it true

Tags
static
access

private

Return values
bool

The Customers' e-mail address on success, false otherwise

sendLogin()

Sends the Customer login data

public static sendLogin(string $email, string $password) : bool

Note that this only works as expected after the Customer has logged in, but before the Customer is redirected to an online payment service provider, as the session usually gets lost in the process. So, it's best to call this right after storing the Order, before the payment transaction is started.

Parameters
$email : string

The e-mail address

$password : string

The password

Return values
bool

True on success, false otherwise

setJsCart()

Sets up the JavsScript cart

public static setJsCart() : void

Searches all $themesPages elements for the first occurrence of the "shopJsCart" template block. Generates the structure of the Javascript cart, puts it in the template, and registers all required JS code. Note that this is only ever called when the JS cart is enabled in the extended settings!

Tags
access

public

global

array $_ARRAYLANG Language array

global

array $themesPages Theme template array

static

setNavbar()

Sets up the Shop Navbar in the global Template only

public static setNavbar() : mixed

To get the content for use with another Template, see getNavbar()

Tags
global

$objTemplate

global

$themesPages

showCategories()

Set up the subcategories block in the current shop page.

public static showCategories([int $parent_id = 0 ]) : bool
Parameters
$parent_id : int = 0

The optional parent ShopCategory ID, defaults to 0 (zero).

Tags
global

array

Return values
bool

True on success, false otherwise

showCustomerDiscount()

Show the total pending order and the resulting discount amount.

public static showCustomerDiscount(float $orderAmount) : bool

This method fails if there is no Customer logged in or if there is some weird problem with the Discount class.

Parameters
$orderAmount : float

The amount of the current order

Tags
global

array $_ARRAYLANG Language array

author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise.

showDiscountInfo()

Set up the full set of discount information placeholders

public static showDiscountInfo(int $groupCustomerId, int $groupArticleId, int $groupCountId, int $count) : mixed
Parameters
$groupCustomerId : int

The customer group ID of the current customer

$groupArticleId : int

The article group ID of the current article

$groupCountId : int

The count discount group ID of the current article

$count : int

The number of articles to be used for the count discount

Tags
static
author

Reto Kohli reto.kohli@comvation.com

showShipmentTerms()

Set up the template block with the shipment terms and conditions

public static showShipmentTerms() : mixed

Please DO NOT remove this method, despite the site terms and conditions have been removed from the Shop! This has been requested by some shopkeepers and may be used at will.

Tags
global

array $_ARRAYLANG Language array

author

Reto Kohli reto.kohli@comvation.com

stripUniqidFromFilename()

Remove the uniqid part from a file name that was added after uploading the file

public static stripUniqidFromFilename(string $strFilename) : string

The file name to be matched should look something like filename[uniqid].ext Where uniqid is a 13 digit hexadecimal value created by uniqid(). This method will then return filename.ext

Parameters
$strFilename : string

The file name with the uniqid

Return values
string

The original file name

success()

The payment process has completed successfully.

public static success() : mixed

Check the data from the payment provider.

Tags
access

public

update_session()

Updates the session with all data relevant to the current order

public static update_session() : mixed
  • Counts the items in the Cart, sums up the amounts
  • Calculates all taxes and fees Sets fields in the global $_SESSION['shop'] array, namely 'grand_total_price', 'vat_price', 'vat_products_txt', 'vat_grand_txt', and 'vat_procentual'.

uploadFile()

Upload a file to be associated with a product in the cart

public static uploadFile(string $fileName) : string
Parameters
$fileName : string

upload file name

Tags
author

Reto Kohli reto.kohli@comvation.com

static
Return values
string

The file name on success, the empty string otherwise

use_session()

Returns true if the Shop will require a session

public static use_session() : bool

A session must be initialized if

  • it has been initialized before (the session cookie is set),
  • the customer changes the currency,
  • the customer looks at Product details (for the "looked at" history), or
  • the customer puts an article into the cart. In the above cases, this will return true, false otherwise. If true is returned, the caller MUST verify the existence of an active session (by checking the state of global $_SESSION) and, if that is empty, instantiate it. See init() for more.
Return values
bool

True if a session is required, false otherwise

verify_account()

Verifies the account data present in the session

public static verify_account([bool $silent = false ]) : bool
Parameters
$silent : bool = false

If true, no messages are created. Defaults to false

Return values
bool

True if the account data is complete and valid, false otherwise

verify_payment_details()

public static verify_payment_details() : mixed

verifySessionAddress()

Returns true if the cart is non-empty and all necessary address information has been stored in the session

public static verifySessionAddress() : bool
Return values
bool

True on success, false otherwise

view_account()

public static view_account() : mixed

view_cart()

The cart view

public static view_cart() : mixed
Tags
global

array $_ARRAYLANG Language array

view_lsv_form()

Set up the "lsv_form" page with the user information form for LSV

public static view_lsv_form() : mixed
Tags
todo

Fill in the order summary automatically.

todo

Problem: If the order is big enough, it may not fit into the visible text area, thus causing some order items to be cut off when printed. This issue should be resolved by replacing the

<textarea> with a variable height element, such as a table, or a div.
global

ADONewConnection $objDatabase Database connection object

global

array $_ARRAYLANG Language array

view_payment()

The payment and shipment selection view

public static view_payment() : void

view_product_overview()

Set up the shop page with products and discounts

public static view_product_overview([array<string|int, mixed> $product_ids = null ]) : bool
Parameters
$product_ids : array<string|int, mixed> = null

The optional array of Product IDs. Overrides any URL parameters if set

Tags
global

ADONewConnection $objDatabase Database connection object

global

array $_ARRAYLANG Language array

global

array $_CONFIG Core configuration array, see

global

string(?) $themesPages Themes pages(?)

Return values
bool

True on success, false otherwise

viewpart_lsv()

Set up the LSV partial view (internal LSV form provider)

public static viewpart_lsv() : mixed

Returns immediately if LSV is not the selected payment type. Currently, this is implemented as an optional part of the payment view.

Tags
global

array $_ARRAYLANG Language array

getXmlSitemap()

protected static getXmlSitemap() : mixed

parseImagesOfProduct()

protected static parseImagesOfProduct(Product $product, Sigma $template, int $formId) : string
Parameters
$product : Product
$template : Sigma
$formId : int

Index of the product being parsed.

Return values
string

Absolute URL to the main image of the product.

preProcessImageDataOfProduct()

protected static preProcessImageDataOfProduct(array<string|int, mixed> $imageData, array<string|int, mixed> $thumbnailFormats, int $formId) : array<string|int, mixed>
Parameters
$imageData : array<string|int, mixed>

Decoded image data of product to be processed.

$thumbnailFormats : array<string|int, mixed>

List of thumbnail formats defined by ThumbnailGenerator of MediaSource.

$formId : int

Index of the product being parsed.

Return values
array<string|int, mixed>

Associative array of processed image data from $imageData.

viewShipmentDiscount()

Set up the Shipment discount template block

protected static viewShipmentDiscount() : mixed

Informs the Customer whether the Coupon applies to the Shipment cost. If shipping is required, not free, and a valid Coupon with amount > 0 is used, touches one of these blocks:

  • shipment_discount_applied_info As much as possible of the remaining amount has been applied to the Shipment cost.
  • shipment_discount_enabled_info Shipment discounts are enabled, but the Coupon has no value left.
  • shipment_discount_disabled_info Shipment discounts are disabled, and thus do not apply.

_authenticate()

Authenticate a Customer

private static _authenticate() : bool
Tags
global

ADONewConnection $objDatabase Database connection object

access

private

Return values
bool

True if the Customer could be authenticated successfully, false otherwise.

init_session()

Initialises the session with regard to the Shop

private static init_session() : void

Does nothing but return if either

  • the visitor is a known spider bot, or
  • use_session() returns false

rememberVisitedProducts()

Remembers the last visited Product IDs

private static rememberVisitedProducts(int $product_id) : void

Returns immediately, without doing anything, if no session is active. The limit for the number of Products to remember is defined by the numof_remember_visited_products class constant.

Parameters
$product_id : int

The currently viewed Product ID


        
On this page

Search results