\Cairn_Post_Set

Functions for working with post sets for carts, holds and orders stored for guests based on a cookie.

Summary

Methods
Properties
Constants
ajax_posts_set_calculate()
ajax_posts_set_quantity()
ajax_posts_set_add_post()
ajax_posts_set_remove_post()
get_set_by_id()
get_post_set_ids()
query_posts_set()
get()
save()
update()
products()
check_cart_status()
expire()
shipped()
hold_expired()
available()
solds()
holds()
db_install()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

ajax_posts_set_calculate()

ajax_posts_set_calculate()

AJAX callback to calculate the total cost for the post set including shipping costs.

Requires the following paramaters:

  • zip string The destination zip code.
  • country string The destination country.
  • method string The method of payment: 'btc' (BTC) or 'credit' (USD)

JSON Object is printed which includes the following attributes:

  • success boolean If the calculation was successful.
  • message string The text that should be displayed to the user.
  • prices array The list of individual prices for items.
    • id integer The ID of the item/post
    • total array The total price for the item.
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • printing array The total for printing
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • framing array The total for framing
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • production array The total for production
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • artist array The total for artist fees
      • BTC float In Bitcoins
      • USD float In United States Dollars
  • calculated array The breakdown of how much is spent on each service.
    • printing array The price of all printing
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • framing array The price of all framing
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • production array The price of all production
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • artist array The price of all artist fees
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • shipping array The price of all shipping
      • BTC float In Bitcoins
      • USD float In United States Dollars
    • fees array The price of all fees
      • BTC float In Bitcoins
      • USD float In United States Dollars
  • method string The method of payment: 'btc' or 'credit'
  • total_btc float The grand total for Bitcoins.
  • total_usd float The grand total for United States Dollars.

ajax_posts_set_quantity()

ajax_posts_set_quantity()

AJAX callback to calculate the total cost for the post set including shipping costs.

Requires the following paramaters:

  • selected_post array An associative array on which item to change.
    • id integer The existing item/post ID
    • option integer The existing option number
    • quantity integer The new quantity

JSON Object is printed which includes the following attributes:

  • success boolean If the calculation was successful.
  • message string The text that should be displayed to the user.

ajax_posts_set_add_post()

ajax_posts_set_add_post()

AJAX callback to add a new item/post to the post_set that must be a status of cart.

Requires the following paramaters:

  • selected_post array An associative array on which item to change.
    • id integer The item/post ID
    • option integer The option number
    • quantity integer The quantity

JSON Object is printed which includes the following attributes:

  • success boolean If the calculation was successful.
  • message string The text that should be displayed to the user.

ajax_posts_set_remove_post()

ajax_posts_set_remove_post()

AJAX callback to remove an item/post from the post_set that must be a status of cart.

Requires the following paramaters:

  • selected_post array An associative array on which item to change.
    • id integer The existing item/post ID
    • option integer The existing option number

JSON Object is printed which includes the following attributes:

  • success boolean If the calculation was successful.
  • message string The text that should be displayed to the user.

get_set_by_id()

get_set_by_id(string $id) : array|false

Returns a post_set from its ID

Parameters

string $id

The posts_set ID

Returns

array|false —
  • post_set object The direct database object result.
  • posts array An array of posts for the post set.
  • products array An array of the post IDs from the post set.

get_post_set_ids()

get_post_set_ids(string $hash) : array

Returns all the item/posts IDs for a post_set from the hash

Parameters

string $hash

The hash for the post_set

Returns

array —

The post IDs in the set.

query_posts_set()

query_posts_set(string $hash) : boolean

Replaces the main database query_posts to only get the posts from a post set.

Parameters

string $hash

The posts_set hash.

Returns

boolean —

If the database query was successful.

get()

get(string $hash) : array

Get all information about a post_set

Parameters

string $hash

The posts_set hash.

Returns

array —
  • id string The id of the post set
  • products array The items/posts/products in the post set:
    • id integer The id of the item/post
    • option integer The option number for the item
    • quantity integer The quantity of the items
    • post object The item as returned by Cairn::loop
  • status string The status of the cart.
  • hash string The hash for the cart.
  • method _string The method of payment for the set, 'btc' or 'credit'.
  • total_usd float The total price for the set in United States Dollars.
  • total_btc float The total price for the set in Bitcoin.
  • calculated array The calculated totals for each service (see: ajax_posts_set_calculate)

save()

save(string $id, string $hash, array $products) : boolean

Save a new post set

Parameters

string $id

The id for the set.

string $hash

The hash for the set.

array $products
  • id integer The item/post ID
  • option integer The option number
  • quantity integer The quantity

Returns

boolean —

If the save was successful.

update()

update(string $id, string $hash, array $products) : boolean

Update a post set in the database

Parameters

string $id

The id for the set.

string $hash

The hash for the set.

array $products
  • id integer The item/post ID
  • option integer The option number
  • quantity integer The quantity

Returns

boolean —

If the save was successful.

products()

products(string $id) : object

Returns the posts for a post set

Parameters

string $id

The id for the set.

Returns

object —
  • id string The id for the row
  • post_set_id string The id for the post set
  • post_id integer The item/post ID
  • post_option integer The option number
  • post_quantity integer The quantity

check_cart_status()

check_cart_status(string $hash) : boolean

Returns the posts for a post set

Parameters

string $hash

The hash for the set.

Returns

boolean —

If the post set is a cart.

expire()

expire(string $id) : array

Change the status of a post set to expire.

Parameters

string $id

The id for the set.

Returns

array —
  • success boolean If the change was successful.
  • message string The message to display to the user.

shipped()

shipped(string $id) : array

Change the status of a post set to shipped.

Parameters

string $id

The id for the set.

Returns

array —
  • success boolean If the change was successful.
  • message string The message to display to the user.

hold_expired()

hold_expired(object $order, string $format) : boolean|string

Check, update and return the hold status of a post set.

Parameters

object $order

The post_set object

string $format

The format to return the time remaining.

Returns

boolean|string —

The time remaining if the item is not expired otherwise returns false.

available()

available(integer $quantity, integer $post_id, integer $post_option) : boolean|integer

Calculates if the item is still available in the desired quantity.

Parameters

integer $quantity

The desired quantity for an item/post

integer $post_id

The post_id to check

integer $post_option

The post purchase option to check

Returns

boolean|integer —

The number of items available or true/false.

solds()

solds(integer $post_id, integer $post_option) : integer

Calculates the number of times the item has been sold.

Parameters

integer $post_id

The post_id to check.

integer $post_option

The post purchase option to check.

Returns

integer —

The number of items sold.

holds()

holds(integer $post_id, integer $post_option) : integer

Calculates the number of times the item is on hold.

Parameters

integer $post_id

The post_id to check.

integer $post_option

The post purchase option to check.

Returns

integer —

The number of times the item is on hold.

db_install()

db_install()

Callback to install database scheme.