swipestripe
[ class tree: swipestripe ] [ index: swipestripe ] [ all elements ]

Class: Product_Controller

Source Location: /code/product/Product.php

Class Overview

Page_Controller
   |
   --Product_Controller

Displays a product, add to cart form, gets options and variation price for a Product via AJAX.


Author(s):

Version:

  • 1.0

Copyright:

  • Copyright (c) 2011, Frank Mullenger

Variables

Methods



Class Details

[line 743]
Displays a product, add to cart form, gets options and variation price for a Product via AJAX.



Tags:

author:  Frank Mullenger <frankmullenger@gmail.com>
version:  1.0
copyright:  Copyright (c) 2011, Frank Mullenger


[ Top ]


Class Variables

static $allowed_actions = array (
     'add',
    'options',
    'AddToCartForm',
    'variationprice',
    'index'
  )

[line 750]

Allowed actions for this controller



Tags:

access:  public

Type:   Array


[ Top ]

static $url_handlers = array( 
    '' => 'index',
     'AddToCartForm' => 'AddToCartForm',
    'add' => 'add',
     'options' => 'options',
    'variationprice' => 'variationprice',
     
    '$ID!/AddToCartForm' => 'AddToCartForm',
    '$ID!/add' => 'add',
    '$ID/options' => 'options',
    '$ID/variationprice' => 'variationprice',
     '$ID!' => 'index',
  )

[line 767]

URL handlers to redirect URLs of the type /product/[Product URL Segment] to the correct actions. As well as directing norman nested URLs to the same actions. This is so that Products without a ParentID (not part of the site tree) can be accessed from a nicely formatted generic URL.



Tags:

access:  public

Type:   Array


[ Top ]



Class Methods


method add [line 898]

void add( Array $data, Form $form)

Add an item to the current cart (Order) for a given Product.



Parameters:

Array   $data  
Form   $form  

[ Top ]

method AddToCartForm [line 852]

void AddToCartForm( [Int $quantity = null], [String $redirectURL = null])

Add to cart form for adding Products, to show on the Product page.



Parameters:

Int   $quantity  
String   $redirectURL   A URL to redirect to after the product is added, useful to redirect to cart page

[ Top ]

method index [line 820]

void index( SS_HTTPRequest $request)

Display a Product.



Parameters:

SS_HTTPRequest   $request  

[ Top ]

method init [line 786]

void init( )

Include some CSS and set the dataRecord to the current Product that is being viewed.



[ Top ]

method options [line 989]

String options( SS_HTTPRequest $request)

Get options for a product and return for use in the form Must get options for nextAttributeID, but these options should be filtered so that only the options for the variations that match attributeID and optionID are returned.

In other words, do not just return options for a product, return options for product variations.

Usually called via AJAX.




Tags:

return:  JSON encoded string for use to update options in select fields on Product page
access:  public


Parameters:

SS_HTTPRequest   $request  

[ Top ]

method variationprice [line 1050]

String variationprice( SS_HTTPRequest $request)

Calculate the Variation price difference based on current request.

Current seleted options are passed in POST vars, if a matching Variation can be found, the price difference of that Variation is returned for display on the Product page.

TODO return the total here as well




Tags:

return:  JSON encoded string of price difference


Parameters:

SS_HTTPRequest   $request  

[ Top ]


Documentation generated on Thu, 08 Mar 2012 16:47:28 +1300 by phpDocumentor 1.4.4