本文整理汇总了PHP中ShoppOrder函数的典型用法代码示例。如果您正苦于以下问题:PHP ShoppOrder函数的具体用法?PHP ShoppOrder怎么用?PHP ShoppOrder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ShoppOrder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setobject
/**
* _setobject - returns the global context object used in the shopp('cartitem) call
*
* @internal
* @since 1.2
*
* @return ShoppCartItem|bool The working ShoppCartItem context
**/
public static function _setobject($Object, $object)
{
if (is_object($Object) && is_a($Object, 'Item')) {
return $Object;
}
if (strtolower($object) != 'cartitem') {
return $Object;
} else {
$Cart = ShoppOrder()->Cart;
$Item = false;
if (isset($Cart->_item_loop)) {
$Item = $Cart->current();
$Item->_id = $Cart->key();
return $Item;
} elseif (isset($Cart->_shipped_loop)) {
$Item = current($Cart->shipped);
$Item->_id = key($Cart->shipped);
return $Item;
} elseif (isset($Cart->_downloads_loop)) {
$Item = current($Cart->downloads);
$Item->_id = key($Cart->downloads);
return $Item;
}
return false;
}
}
示例2: ShoppCustomer
/**
* Get and set the global ShoppCustomer object
*
* @api
* @since 1.2
*
* @param ShoppCustomer $Object (optional) the specified ShoppCustomer object
* @return ShoppCustomer the current global customer object
**/
function ShoppCustomer($Object = false)
{
$Order = ShoppOrder();
if ($Object && is_a($Object, 'ShoppCustomer')) {
$Order->Customer = $Object;
}
return $Order->Customer;
}
示例3: checkout
function checkout()
{
if (version_compare(SHOPP_VERSION, '1.1.9', '<=')) {
$this->Order->Billing->cardtype = "BillmateBank";
$this->Order->confirm = true;
} else {
$Order = ShoppOrder();
$Order->Billing->cardtype = 'BillmateBank';
$Order->confirm = true;
}
}
示例4: checkout
function checkout()
{
if (version_compare(SHOPP_VERSION, '1.1.9', '<=')) {
$this->Order->Billing->cardtype = "BillmateCardpay";
$this->Order->confirm = true;
$this->Order->capture = $this->settings['authentication_method'] == 'sale' ? 'YES' : 'NO';
} else {
$Order = ShoppOrder();
$Order->Billing->cardtype = 'BillmateCardpay';
$Order->capture = $this->settings['authentication_method'] == 'sale' ? 'YES' : 'NO';
$Order->confirm = true;
}
}
示例5: login
public static function login($result)
{
$Customer = ShoppOrder()->Customer;
if ($Customer->loggedin()) {
return $result;
}
$accounts = shopp_setting('account_system');
$pleaselogin = ' ' . Shopp::__('If you have an account with us, please login now.');
// This specific !isset condition checks if the loginname is not provided
// If no loginname is provided, but an account system is used, we need to
// generate a new login name for the customer
if ('wordpress' == $accounts && !isset($_POST['loginname'])) {
ShoppLoginGenerator::object();
$_POST['loginname'] = ShoppLoginGenerator::name();
if (apply_filters('shopp_login_required', empty($_POST['loginname']))) {
return shopp_add_error(Shopp::__('A login could not be created with the information you provided. Enter a different name or email address.') . $pleaselogin);
}
shopp_debug('Login set to ' . $_POST['loginname'] . ' for WordPress account creation.');
}
// Validate unique email address for new account
if (in_array($accounts, array('wordpress', 'shopp')) && !$Customer->session(ShoppCustomer::GUEST)) {
$ShoppCustomer = new ShoppCustomer($_POST['email'], 'email');
if (apply_filters('shopp_email_exists', 'wordpress' == $accounts ? email_exists($_POST['email']) : $ShoppCustomer->exists())) {
return shopp_add_error(Shopp::__('The email address you entered is already in use. Enter a different email address to create a new account.') . $pleaselogin);
}
}
// Validate WP login
if (isset($_POST['loginname'])) {
if (apply_filters('shopp_login_required', empty($_POST['loginname']))) {
return shopp_add_error(Shopp::__('You must enter a login name for your account.'));
}
if (apply_filters('shopp_login_valid', !validate_username($_POST['loginname']))) {
$sanitized = sanitize_user($_POST['loginname'], true);
$illegal = array_diff(str_split($_POST['loginname']), str_split($sanitized));
return shopp_add_error(Shopp::__('The login name provided includes invalid characters: %s', esc_html(join(' ', $illegal))));
}
if (apply_filters('shopp_login_exists', username_exists($_POST['loginname']))) {
return shopp_add_error(Shopp::__('"%s" is already in use. Enter a different login name to create a new account.', esc_html($_POST['loginname'])) . $pleaselogin);
}
}
return $result;
}
示例6: totals
/**
* Calculates the order Totals
*
* @author Jonathan Davis
* @since 1.3
*
* @return void
**/
public function totals()
{
// Setup totals counter
if (false === $this->Totals) {
$this->Totals = new OrderTotals();
}
$Totals = $this->Totals;
do_action('shopp_cart_totals_init', $Totals);
$Shipping = ShoppOrder()->Shiprates;
$Discounts = ShoppOrder()->Discounts;
// Identify downloadable products
$downloads = $this->downloads();
$shipped = $this->shipped();
do_action('shopp_cart_item_totals', $Totals);
// Update cart item totals
$items = $this->keys();
// Use local array for iterating
foreach ($items as $itemid) {
// Allow other code to iterate the cart in this loop
$Item = $this->get($itemid);
$Item->totals();
}
$Totals->register(new OrderAmountShipping(array('id' => 'cart', 'amount' => $Shipping->calculate())));
if (apply_filters('shopp_tax_shipping', shopp_setting_enabled('tax_shipping'))) {
$Totals->register(new OrderAmountShippingTax($Totals->total('shipping')));
}
// Calculate discounts
$Totals->register(new OrderAmountDiscount(array('id' => 'cart', 'amount' => $Discounts->amount())));
// Apply credits to discount the order
$Discounts->credits();
if ($Discounts->shipping()) {
// If shipping discounts changed, recalculate shipping amount
$Totals->register(new OrderAmountShipping(array('id' => 'cart', 'amount' => $Shipping->calculate())));
}
// Ensure taxes are recalculated
$Totals->total('tax');
do_action_ref_array('shopp_cart_retotal', array(&$Totals));
return $Totals;
}
示例7: smart
public function smart(array $options = array())
{
$this->name = __('Customers also bought…', 'Shopp');
$this->controls = false;
$where = array("true=false");
$scope = array();
$Product = ShoppProduct();
$Order = ShoppOrder();
$Cart = $Order->Cart;
// Use the current product is available
if (!empty($Product->id)) {
$this->product = $Product;
}
// Or load a product specified
if (!empty($options['product'])) {
if ('recent-cartitem' == $options['product']) {
// Use most recently added item in the cart
$this->product = new ShoppProduct($Cart->added()->product);
} elseif (preg_match('/^[\\d+]$/', $options['product'])) {
// Load by specified id
$this->product = new ShoppProduct($options['product']);
} else {
$this->product = new ShoppProduct($options['product'], 'slug');
// Load by specified slug
}
}
if (empty($this->product->id)) {
$loading = compact('where');
$this->loading = array_merge($options, $loading);
return;
}
$this->name = Shopp::__('Customers that bought "%s" also bought…', $this->product->name);
$purchased = ShoppDatabaseObject::tablename(Purchased::$table);
$query = "SELECT p2,((psum - (sum1 * sum2 / n)) / sqrt((sum1sq - pow(sum1, 2.0) / n) * (sum2sq - pow(sum2, 2.0) / n))) AS r, n\n\t\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\t\tSELECT n1.product AS p1,n2.product AS p2,SUM(n1.quantity) AS sum1,SUM(n2.quantity) AS sum2,\n\t\t\t\t\t\t\t\t\t\tSUM(n1.quantity * n1.quantity) AS sum1sq,SUM(n2.quantity * n2.quantity) AS sum2sq,\n\t\t\t\t\t\t\t\t\t\tSUM(n1.quantity * n2.quantity) AS psum,COUNT(*) AS n\n\t\t\t\t\t\t\t\t\tFROM {$purchased} AS n1\n\t\t\t\t\t\t\t\t\tLEFT JOIN {$purchased} AS n2 ON n1.purchase = n2.purchase\n\t\t\t\t\t\t\t\t\tWHERE n1.product != n2.product\n\t\t\t\t\t\t\t\t\tGROUP BY n1.product,n2.product\n\t\t\t\t\t\t\t\t) AS step1\n\t\t\t\t\t\t\t\tORDER BY r DESC, n DESC";
$cachehash = 'alsobought_' . md5($query);
$cached = Shopp::cache_get($cachehash, 'shopp_collection_alsobought');
if ($cached) {
$matches = $cached;
} else {
$matches = sDB::query($query, 'array', 'col', 'p2');
Shopp::cache_set($cachehash, $matches, 'shopp_collection_alsobought', 14400);
//Expires in 4 hours
}
if (empty($matches)) {
$loading = compact('where');
$this->loading = array_merge($options, $loading);
return;
}
$where = array("p.id IN (" . join(',', $matches) . ")");
$loading = compact('columns', 'joins', 'where', 'groupby', 'order');
$this->loading = array_merge($options, $loading);
if (isset($options['controls']) && Shopp::str_true($options['controls'])) {
unset($this->controls);
}
}
示例8: submit_login
/**
* Provides the submit login button markup
*
* @api `shopp('customer.submit-login')`
* @since 1.0
*
* @param string $result The output
* @param array $options The options
* - **autocomplete**: (on, off) Specifies whether an `<input>` element should have autocomplete enabled
* - **accesskey**: Specifies a shortcut key to activate/focus an element. Linux/Windows: `[Alt]`+`accesskey`, Mac: `[Ctrl]``[Opt]`+`accesskey`
* - **class**: The class attribute specifies one or more class-names for an element
* - **disabled**: Specifies that an `<input>` element should be disabled
* - **placeholder**: Specifies a short hint that describes the expected value of an `<input>` element
* - **required**: Adds a class that specified an input field must be filled out before submitting the form, enforced by JS
* - **tabindex**: Specifies the tabbing order of an element
* - **title**: Specifies extra information about an element
* - **label**: Specifies the value of the button element. Defaults to `Login`
* - **redirect**: Specifies the URL the customer is redirected to after login. Defaults to `$_REQUEST['redirect']`.
* @param ShoppCustomer $O The working object
* @return string The button markup
**/
public static function submit_login($result, $options, $O)
{
$request = $_GET;
$defaults = array('label' => Shopp::__('Login'), 'redirect' => isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : Shopp::url($request, 'account', ShoppOrder()->security()));
$options = array_merge($defaults, $options);
extract($options, EXTR_SKIP);
$string = '';
$id = 'submit-login';
$context = ShoppStorefront::intemplate();
if (isset($request['acct']) && 'logout' == $request['acct']) {
unset($request['acct']);
}
if ('checkout.php' == $context) {
$redirect = 'checkout';
$id .= '-' . $redirect;
}
return '<input type="hidden" name="redirect" value="' . esc_attr($redirect) . '" />' . '<input type="submit" name="submit-login" id="' . $id . '"' . inputattrs($options) . ' />';
}
示例9: fromshipping
public function fromshipping()
{
$Shipping = ShoppOrder()->Shipping;
$fields = array($this->address, $this->xaddress, $this->city);
$address = join('', $fields);
if (empty($address)) {
$this->copydata($Shipping, '', array('type'));
}
}
示例10: order_data
/**
* Provides a custom text field for collecting any number of custom order fields
*
* @api `shopp('checkout.order-data')`
* @since 1.0
*
* @param string $result The output
* @param array $options The options
* - **name**: **REQUIRED** The name of the customer info field
* - **mode**: `input` (input, value) Provide the `input` markup or the current `value` of the `name` field
* - **type**: `hidden` (textarea, menu, hidden, radio, checkbox, button, submit) The type of input markup to generate
* - **options**: Comma-separated option values
* - **autocomplete**: (on, off) Specifies whether an `<input>` element should have autocomplete enabled
* - **accesskey**: Specifies a shortcut key to activate/focus an element. Linux/Windows: `[Alt]`+`accesskey`, Mac: `[Ctrl]``[Opt]`+`accesskey`
* - **alt**: Specifies an alternate text for images (only for type="image")
* - **checked**: Specifies that an `<input>` element should be pre-selected when the page loads (for type="checkbox" or type="radio")
* - **class**: The class attribute specifies one or more class-names for an element
* - **disabled**: Specifies that an `<input>` element should be disabled
* - **format**: Specifies special field formatting class names for JS validation
* - **minlength**: Sets a minimum length for the field enforced by JS validation
* - **maxlength**: Specifies the maximum number of characters allowed in an `<input>` element
* - **placeholder**: Specifies a short hint that describes the expected value of an `<input>` element
* - **readonly**: Specifies that an input field is read-only
* - **required**: Adds a class that specified an input field must be filled out before submitting the form, enforced by JS
* - **size**: Specifies the width, in characters, of an `<input>` element
* - **src**: Specifies the URL of the image to use as a submit button (only for type="image")
* - **tabindex**: Specifies the tabbing order of an element
* - **cols**: Specifies the visible width of a `<textarea>`
* - **rows**: Specifies the visible number of lines in a `<textarea>`
* - **title**: Specifies extra information about an element
* - **value**: Specifies the value of an `<input>` element
* @param ShoppOrder $O The working object
* @return string The custom order data field markup
**/
public static function order_data($result, $options, $O)
{
$select_attrs = array('title', 'class', 'disabled', 'required', 'size', 'tabindex', 'accesskey');
$defaults = array('name' => false, 'data' => false, 'mode' => false, 'title' => '', 'type' => 'hidden', 'value' => '', 'options' => '');
if (isset($options['name']) && array_key_exists($options['name'], ShoppOrder()->data)) {
$defaults['value'] = ShoppOrder()->data[$options['name']];
}
if (isset($options['type']) && 'textarea' == $options['type']) {
$defaults['cols'] = '30';
$defaults['rows'] = '3';
}
$op = array_merge($defaults, $options);
extract($op);
// Allowed input types
$allowed_types = array("text", "hidden", "password", "checkbox", "radio", "textarea", "menu");
// Input types that can override option-specified value with the loaded data value
$value_override = array("text", "hidden", "password", "textarea", "menu");
/// Allowable attributes for textarea inputs
$textarea_attrs = array('accesskey', 'title', 'tabindex', 'class', 'disabled', 'required', 'maxlength');
if (!$name) {
// Iterator for order data
if (!isset($O->_data_loop)) {
reset($O->data);
$O->_data_loop = true;
} else {
next($O->data);
}
if (current($O->data) !== false) {
return true;
} else {
unset($O->_data_loop);
return false;
}
}
if (isset($O->data[$name])) {
$data = $O->data[$name];
}
if ($name && $mode == "value") {
return apply_filters('shopp_checkout_order_data', $data);
}
if (!in_array($type, $allowed_types)) {
$type = 'hidden';
}
if (empty($title)) {
$title = $name;
}
$id = 'order-data-' . sanitize_title_with_dashes($name);
if (in_array($type, $value_override) && !empty($data)) {
$op['value'] = $value = $data;
}
switch (strtolower($type)) {
case "textarea":
return '<textarea name="data[' . $name . ']" cols="' . $cols . '" rows="' . $rows . '" id="' . $id . '" ' . inputattrs($op, $textarea_attrs) . '>' . $value . '</textarea>';
break;
case "menu":
$menuvalues = true;
if (is_string($options)) {
$menuvalues = false;
$options = explode(',', $options);
}
return '<select name="data[' . $name . ']" id="' . $id . '" ' . inputattrs($op, $select_attrs) . '>' . menuoptions($options, $value, $menuvalues) . '</select>';
break;
default:
return '<input type="' . $type . '" name="data[' . $name . ']" id="' . $id . '" ' . inputattrs($op) . ' />';
break;
}
//.........这里部分代码省略.........
示例11: amount
/**
* Formats monetary amounts for handing off to the gateway
*
* Supports specifying an order total by name (subtotal, tax, shipping, total)
*
* @author Jonathan Davis
* @since 1.2
*
* @param string|float|int $amount The amount (or name of the amount total) to format
* @return string Formatted amount
**/
public function amount($amount, array $format = array())
{
$register = false;
if (is_string($amount)) {
$register = $amount;
$Cart = ShoppOrder()->Cart;
$amount = $Cart->total($amount);
if (false === $amount) {
$register = false;
}
} elseif (!(is_int($amount) || is_float($amount))) {
return $amount;
}
$defaults = array('precision' => $this->precision, 'decimals' => $this->decimals, 'thousands' => $this->thousands);
$format = array_merge($defaults, $format);
extract($format);
if (!empty($register)) {
// Allow targeting specific amounts for filtering
$amount = apply_filters("shopp_gateway_{$register}_amount", $amount);
}
$amount = apply_filters('shopp_gateway_amount', abs($amount));
return number_format($amount, $precision, $decimals, $thousands);
}
示例12: shopp_rmv_cart_item_addon
/**
* Removes an addon from a cartitem. The addonkey should be the numeric ID of the addon.
*
* @api
*
* @param mixed $itemkey
* @param mixed $addonkey
* @return bool
*/
function shopp_rmv_cart_item_addon($itemkey = false, $addonkey = false)
{
$Order = ShoppOrder();
$exists = false;
if (false === $itemkey || false === $addonkey) {
shopp_debug(__FUNCTION__ . " failed: item and addon parameter required.");
return false;
}
if (!($item = shopp_cart_item($itemkey))) {
shopp_debug(__FUNCTION__ . " failed: no such item {$itemkey}");
return false;
}
if (false === ($addons = shopp_cart_item_addons($itemkey))) {
return false;
// Debug message will already have been generated in shopp_cart_item_addons()
}
if (!isset($addons[$addonkey])) {
shopp_debug(__FUNCTION__ . " failed: addon {$addonkey} was not found in item {$itemkey}");
return false;
}
$revised = array();
foreach ($addons as $addon) {
if ($addonkey == $addon->id) {
$revised[] = (int) ($addonkey * -1);
} else {
$revised[] = $addon->id;
}
}
return $Order->Cart->change($itemkey, $item->product, (int) $item->priceline, $revised);
}
示例13: in_cart
/**
* Checks if the current product is in the shopping cart
*
* @api `shopp('product.in-cart')`
* @since 1.1
*
* @param string $result The output
* @param array $options The options
* @param ShoppProduct $O The working object
* @return bool True if the product is in the cart, false otherwise
**/
public static function in_cart($result, $options, $O)
{
$Cart = ShoppOrder()->Cart;
if ($Cart->count == 0) {
return false;
}
// Cart is empty
foreach ($Cart as $Item) {
if ($Item->product == $O->id) {
return true;
}
}
return false;
}
示例14: taxrates
/**
* Determines all applicable tax rates for the store or an item
*
* @author Jonathan Davis
* @since 1.0
* @version 1.3
*
* @param Object $Item (optional) The ShoppProduct, ShoppCartItem or ShoppPurchased object to find tax rates for
* @return float The determined tax rate
**/
public static function taxrates($Item = null)
{
$Tax = new ShoppTax();
$Order = ShoppOrder();
// Setup taxable address
$Tax->address($Order->Billing, $Order->Shipping, $Order->Cart->shipped());
$taxes = array();
if (is_null($Item)) {
$Tax->rates($taxes);
} else {
$Tax->rates($taxes, $Tax->item($Item));
}
return apply_filters('shopp_taxrates', $taxes);
}
示例15: shipping_costs
public function shipping_costs()
{
if (!isset($_GET['method'])) {
die(0);
}
$Order = ShoppOrder();
$Shiprates = $Order->Shiprates;
$selected = $Shiprates->selected();
if ($selected === false || isset($selected->slug) && $_GET['method'] != $selected->slug) {
$Shiprates->selected($_GET['method']);
}
echo (string) $Order->Cart->totals();
exit;
}