當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Shopp::floatval方法代碼示例

本文整理匯總了PHP中Shopp::floatval方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shopp::floatval方法的具體用法?PHP Shopp::floatval怎麽用?PHP Shopp::floatval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Shopp的用法示例。


在下文中一共展示了Shopp::floatval方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: calculate

 public function calculate(&$options, $Order)
 {
     foreach ($this->methods as $slug => $method) {
         $tiers = isset($method['table']) ? $this->tablerate($method['table']) : false;
         if (false === $tiers) {
             continue;
         }
         // Skip methods that don't match at all
         $amount = 0;
         $matched = false;
         $tiers = array_reverse($tiers);
         foreach ($tiers as $tier) {
             extract($tier);
             $amount = Shopp::floatval($rate);
             // Capture the rate amount
             if ($this->weight >= $threshold) {
                 $matched = true;
                 break;
             }
         }
         if (!$matched) {
             return $options;
         }
         $rate = array('slug' => $slug, 'name' => $method['label'], 'amount' => $amount, 'delivery' => $this->delivery($method), 'items' => false);
         $options[$slug] = new ShippingOption($rate);
     }
     return $options;
 }
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:28,代碼來源:OrderWeight.php

示例2: screen

 public function screen()
 {
     $Shopp = Shopp::object();
     if (!current_user_can('shopp_settings_checkout')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
     $next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
     $next_setting = shopp_setting('next_order_id');
     if ($next->id > $next_setting) {
         $next_setting = $next->id;
     }
     $term_recount = false;
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-setup-management');
         $next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
         if ($next_order_id >= $next->id) {
             if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
                 $next_setting = $next_order_id;
             }
         }
         $_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
         // Recount terms when this setting changes
         if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
             $term_recount = true;
         }
         shopp_set_formsettings();
         $this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
     }
     if ($term_recount) {
         $taxonomy = ProductCategory::$taxon;
         $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
         }
     }
     $states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
     $statusLabels = shopp_setting('order_status');
     $statesLabels = shopp_setting('order_states');
     $reasonLabels = shopp_setting('cancel_reasons');
     if (empty($reasonLabels)) {
         $reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
     }
     $promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25');
     $lowstock = shopp_setting('lowstock_level');
     if (empty($lowstock)) {
         $lowstock = 0;
     }
     include $this->ui('management.php');
 }
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:50,代碼來源:OrdersSettings.php

示例3: feed

 /**
  * Iterates loaded products in buffered batches and generates a feed-friendly item record
  *
  * NOTE: To modify the output of the RSS generator, use
  * the filter hooks provided in a separate plugin or
  * in the theme functions.php file.
  *
  * @author Jonathan Davis
  * @since 1.0
  * @version 1.1
  *
  * @return string A feed item record
  **/
 public function feed()
 {
     $paged = 100;
     // Buffer 100 products at a time.
     $loop = false;
     $product = ShoppProduct();
     if ($product) {
         $loop = shopp($this, 'products');
         if (!$loop) {
             $product = false;
         } else {
             $product = ShoppProduct();
         }
     }
     if (!($product || $loop)) {
         if (!$this->products) {
             $page = 1;
         } else {
             $page = $this->page + 1;
         }
         if ($this->pages > 0 && $page > $this->pages) {
             return false;
         }
         $this->load(array('load' => array('prices', 'specs', 'categories', 'coverimages'), 'paged' => $paged, 'page' => $page));
         $loop = shopp($this, 'products');
         if (!$loop) {
             return false;
         }
         // Loop ended, bail out
         $product = ShoppProduct();
         if (!$product) {
             return false;
         }
         // No products, bail
     }
     $item = array();
     $item['guid'] = shopp($product, 'get-id');
     $item['title'] = $product->name;
     $item['link'] = shopp($product, 'get-url');
     $item['pubDate'] = date('D, d M Y H:i O', $product->publish);
     // Item Description
     $item['description'] = '';
     $item['description'] .= '<table><tr>';
     $Image = current($product->images);
     if (!empty($Image)) {
         $item['description'] .= '<td><a href="' . $item['link'] . '" title="' . $product->name . '">';
         $item['description'] .= '<img src="' . esc_attr(add_query_string($Image->resizing(75, 75, 0), Shopp::url($Image->id, 'images'))) . '" alt="' . $product->name . '" width="75" height="75" />';
         $item['description'] .= '</a></td>';
     }
     $pricing = "";
     $priceindex = 'price';
     if (Shopp::str_true($product->sale)) {
         $priceindex = 'saleprice';
     }
     if ($product->min[$priceindex] != $product->max[$priceindex]) {
         $pricing .= Shopp::__('from') . ' ';
     }
     $pricing .= money($product->min[$priceindex]);
     $item['description'] .= "<td><p><big>{$pricing}</big></p>";
     $item['description'] .= apply_filters('shopp_rss_description', $product->summary, $product) . '</td></tr></table>';
     $item['description'] = '<![CDATA[' . $item['description'] . ']]>';
     // Google Base Namespace
     // http://www.google.com/support/merchants/bin/answer.py?hl=en&answer=188494
     // Below are Google Base specific attributes
     // You can use the shopp_rss_item filter hook to add new item attributes or change the existing attributes
     if ($Image) {
         $item['g:image_link'] = add_query_string($Image->resizing(400, 400, 0), Shopp::url($Image->id, 'images'));
     }
     $item['g:condition'] = 'new';
     $item['g:availability'] = shopp_setting_enabled('inventory') && $product->outofstock ? 'out of stock' : 'in stock';
     $price = Shopp::floatval(Shopp::str_true($product->sale) ? $product->min['saleprice'] : $product->min['price']);
     if (!empty($price)) {
         $item['g:price'] = $price;
         $item['g:price_type'] = "starting";
     }
     // Include product_type using Shopp category taxonomies
     foreach ($product->categories as $category) {
         $ancestry = array($category->name);
         $ancestors = get_ancestors($category->term_id, $category->taxonomy);
         foreach ((array) $ancestors as $ancestor) {
             $term = get_term($ancestor, $category->taxonomy);
             if ($term) {
                 array_unshift($ancestry, $term->name);
             }
         }
         $item['g:product_type[' . $category->term_id . ']'] = join(' > ', $ancestry);
     }
//.........這裏部分代碼省略.........
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:101,代碼來源:Collection.php

示例4: shiprates


//.........這裏部分代碼省略.........
             }
         } else {
             /** Save shipping calculator settings **/
             $setting = $_POST['id'];
             if (empty($setting)) {
                 // Determine next available setting ID
                 $index = 0;
                 if (is_array($active[$module])) {
                     $index = count($active[$module]);
                 }
                 $setting = "{$module}-{$index}";
             }
             // Cancel editing if saving
             if (isset($_POST['save'])) {
                 unset($_REQUEST['id']);
             }
             $setting_module = $setting;
             $id = 0;
             if (false !== strpos($setting, '-')) {
                 list($setting_module, $id) = explode('-', $setting);
             }
             // Prevent fishy stuff from happening
             if ($module != $setting_module) {
                 $module = false;
             }
             // Save shipping calculator settings
             $Shipper = $Shipping->get($module);
             if ($Shipper && isset($_POST[$module])) {
                 $Shipper->setting($id);
                 $_POST[$module]['label'] = stripslashes($_POST[$module]['label']);
                 // Sterilize $values
                 foreach ($_POST[$module]['table'] as $i => &$row) {
                     if (isset($row['rate'])) {
                         $row['rate'] = Shopp::floatval($row['rate']);
                     }
                     if (!isset($row['tiers'])) {
                         continue;
                     }
                     foreach ($row['tiers'] as &$tier) {
                         if (isset($tier['rate'])) {
                             $tier['rate'] = Shopp::floatval($tier['rate']);
                         }
                     }
                 }
                 // Delivery estimates: ensure max equals or exceeds min
                 ShippingFramework::sensibleestimates($_POST[$module]['mindelivery'], $_POST[$module]['maxdelivery']);
                 shopp_set_setting($Shipper->setting, $_POST[$module]);
                 if (!array_key_exists($module, $active)) {
                     $active[$module] = array();
                 }
                 $active[$module][(int) $id] = true;
                 shopp_set_setting('active_shipping', $active);
                 $this->notice(Shopp::__('Shipping settings saved.'));
             }
         }
     }
     $Shipping->settings();
     // Load all installed shipping modules for settings UIs
     $Shipping->ui();
     // Setup setting UIs
     $installed = array();
     $shiprates = array();
     // Registry for activated shipping rate modules
     $settings = array();
     // Registry of loaded settings for table-based shipping rates for JS
     foreach ($Shipping->active as $name => $module) {
開發者ID:BlessySoftwares,項目名稱:anvelocom,代碼行數:67,代碼來源:System.php

示例5: percentage

 /**
  * Formats a numeric amount to a percentage using a specified format
  *
  * Uses a format configuration array to specify how the amount needs to be
  * formatted.  When no format is specified, the currency format setting
  * is used only paying attention to the decimal precision, decimal symbol and
  * thousands separator.  If no setting is available, a default configuration
  * is used (precision: 1) (decimal separator: .) (thousands separator: ,)
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @param float $amount The amount to format
  * @param array $format A specific format for the number
  * @return string The formatted percentage
  **/
 public static function percentage($amount, $format = array())
 {
     $format = Shopp::currency_format($format);
     extract($format, EXTR_SKIP);
     $float = Shopp::floatval($amount, true, $format);
     $percent = Shopp::numeric_format($float, $precision, $decimals, $thousands, $grouping);
     if (false !== strpos($percent, $decimals)) {
         // Only remove trailing 0's after the decimal
         $percent = rtrim($percent, '0');
         $percent = rtrim($percent, $decimals);
     }
     return "{$percent}%";
 }
開發者ID:BlessySoftwares,項目名稱:anvelocom,代碼行數:29,代碼來源:Core.php

示例6: match_rule

 /**
  * match_rule ()
  * Determines if the value of a given subject matches the rule based
  * on the specified operation */
 static function match_rule($subject, $op, $value, $property = false)
 {
     switch ($op) {
         // String or Numeric operations
         case "Is equal to":
             if ($property && ShoppPromo::$values[$property] == 'price') {
                 return Shopp::floatval($subject) != 0 && Shopp::floatval($value) != 0 && Shopp::floatval($subject) == Shopp::floatval($value);
             } else {
                 if (is_array($subject)) {
                     return in_array($value, $subject);
                 }
                 return "{$subject}" === "{$value}";
             }
             break;
         case "Is not equal to":
             if (is_array($subject)) {
                 return !in_array($value, $subject);
             }
             return "{$subject}" !== "{$value}" || Shopp::floatval($subject) != 0 && Shopp::floatval($value) != 0 && Shopp::floatval($subject) != Shopp::floatval($value);
             break;
             // String operations
         // String operations
         case "Contains":
             if (is_array($subject)) {
                 foreach ($subject as $s) {
                     if (stripos($s, $value) !== false) {
                         return true;
                     }
                 }
                 return false;
             }
             return stripos($subject, $value) !== false;
             break;
         case "Does not contain":
             if (is_array($subject)) {
                 foreach ($subject as $s) {
                     if (stripos($s, $value) !== false) {
                         return false;
                     }
                 }
                 return true;
             }
             return stripos($subject, $value) === false;
             break;
         case "Begins with":
             if (is_array($subject)) {
                 foreach ($subject as $s) {
                     if (stripos($s, $value) === 0) {
                         return true;
                     }
                 }
                 return false;
             }
             return stripos($subject, $value) === 0;
             break;
         case "Ends with":
             if (is_array($subject)) {
                 foreach ($subject as $s) {
                     if (stripos($s, $value) === strlen($s) - strlen($value)) {
                         return true;
                     }
                 }
                 return false;
             }
             return stripos($subject, $value) === strlen($subject) - strlen($value);
             break;
             // Numeric operations
         // Numeric operations
         case "Is greater than":
             return Shopp::floatval($subject, false) > Shopp::floatval($value, false);
             break;
         case "Is greater than or equal to":
             return Shopp::floatval($subject, false) >= Shopp::floatval($value, false);
             break;
         case "Is less than":
             return Shopp::floatval($subject, false) < Shopp::floatval($value, false);
             break;
         case "Is less than or equal to":
             return Shopp::floatval($subject, false) <= Shopp::floatval($value, false);
             break;
     }
     return false;
 }
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:87,代碼來源:Promotion.php

示例7: column_rate

 public function column_rate($Item)
 {
     extract($Item);
     $rate = Shopp::percentage(Shopp::floatval($rate), array('precision' => 4));
     $location = $this->countries[$country];
     $label = "{$rate} &mdash; {$location}";
     $edit_link = wp_nonce_url(add_query_arg('id', $id), 'shopp_edit_taxrate');
     $delete_link = wp_nonce_url(add_query_arg('delete', $id), 'shopp_delete_taxrate');
     echo '<a class="row-title edit" href="' . esc_url($edit_link) . '" title="' . Shopp::__('Edit') . ' &quot;' . esc_attr($label) . '&quot;">' . esc_html($label) . '</a>';
     echo $this->row_actions(array('edit' => '<a class="edit" href="' . $edit_link . '">' . __('Edit') . '</a>', 'delete' => '<a class="delete" href="' . $delete_link . '">' . __('Delete') . '</a>'));
 }
開發者ID:msigley,項目名稱:shopp,代碼行數:11,代碼來源:Taxes.php

示例8: manager

 /**
  * Interface processor for the order manager
  *
  * @author Jonathan Davis
  * @return void
  **/
 public function manager()
 {
     global $Shopp, $Notes;
     global $is_IIS;
     if (!current_user_can('shopp_orders')) {
         wp_die(__('You do not have sufficient permissions to access this page.', 'Shopp'));
     }
     $Purchase = ShoppPurchase();
     $Purchase->Customer = new ShoppCustomer($Purchase->customer);
     $Gateway = $Purchase->gateway();
     if (!empty($_POST["send-note"])) {
         $user = wp_get_current_user();
         shopp_add_order_event($Purchase->id, 'note', array('note' => stripslashes($_POST['note']), 'user' => $user->ID));
         $Purchase->load_events();
     }
     // Handle Order note processing
     if (!empty($_POST['note'])) {
         $this->addnote($Purchase->id, stripslashes($_POST['note']), !empty($_POST['send-note']));
     }
     if (!empty($_POST['delete-note'])) {
         $noteid = key($_POST['delete-note']);
         $Note = new ShoppMetaObject(array('id' => $noteid, 'type' => 'order_note'));
         $Note->delete();
     }
     if (!empty($_POST['edit-note'])) {
         $noteid = key($_POST['note-editor']);
         $Note = new ShoppMetaObject(array('id' => $noteid, 'type' => 'order_note'));
         $Note->value->message = stripslashes($_POST['note-editor'][$noteid]);
         $Note->save();
     }
     $Notes = new ObjectMeta($Purchase->id, 'purchase', 'order_note');
     if (isset($_POST['submit-shipments']) && isset($_POST['shipment']) && !empty($_POST['shipment'])) {
         $shipments = $_POST['shipment'];
         foreach ((array) $shipments as $shipment) {
             shopp_add_order_event($Purchase->id, 'shipped', array('tracking' => $shipment['tracking'], 'carrier' => $shipment['carrier']));
         }
         $updated = __('Shipping notice sent.', 'Shopp');
         // Save shipping carrier default preference for the user
         $userid = get_current_user_id();
         $setting = 'shopp_shipping_carrier';
         if (!get_user_meta($userid, $setting, true)) {
             add_user_meta($userid, $setting, $shipment['carrier']);
         } else {
             update_user_meta($userid, $setting, $shipment['carrier']);
         }
         unset($_POST['ship-notice']);
         $Purchase->load_events();
     }
     if (isset($_POST['order-action']) && 'refund' == $_POST['order-action']) {
         if (!current_user_can('shopp_refund')) {
             wp_die(__('You do not have sufficient permissions to carry out this action.', 'Shopp'));
         }
         $user = wp_get_current_user();
         $reason = (int) $_POST['reason'];
         $amount = Shopp::floatval($_POST['amount']);
         $Purchase->load_events();
         if (!empty($_POST['message'])) {
             $message = $_POST['message'];
             $Purchase->message['note'] = $message;
         }
         if ($amount <= $Purchase->captured - $Purchase->refunded) {
             if (!Shopp::str_true($_POST['send'])) {
                 // Force the order status
                 shopp_add_order_event($Purchase->id, 'notice', array('user' => $user->ID, 'kind' => 'refunded', 'notice' => __('Marked Refunded', 'Shopp')));
                 shopp_add_order_event($Purchase->id, 'refunded', array('txnid' => $Purchase->txnid, 'gateway' => $Gateway->module, 'amount' => $amount));
                 shopp_add_order_event($Purchase->id, 'voided', array('txnorigin' => $Purchase->txnid, 'txnid' => time(), 'gateway' => $Gateway->module));
             } else {
                 shopp_add_order_event($Purchase->id, 'refund', array('txnid' => $Purchase->txnid, 'gateway' => $Gateway->module, 'amount' => $amount, 'reason' => $reason, 'user' => $user->ID));
             }
             if (!empty($_POST['message'])) {
                 $this->addnote($Purchase->id, $_POST['message']);
             }
             $Purchase->load_events();
         } else {
             $this->notice(Shopp::__('Refund failed. Cannot refund more than the current balance.'), 'error');
         }
     }
     if (isset($_POST['order-action']) && 'cancel' == $_POST['order-action']) {
         if (!current_user_can('shopp_void')) {
             wp_die(__('You do not have sufficient permissions to carry out this action.', 'Shopp'));
         }
         // unset($_POST['refund-order']);
         $user = wp_get_current_user();
         $reason = (int) $_POST['reason'];
         $message = '';
         if (!empty($_POST['message'])) {
             $message = $_POST['message'];
             $Purchase->message['note'] = $message;
         } else {
             $message = 0;
         }
         if (!Shopp::str_true($_POST['send'])) {
             // Force the order status
             shopp_add_order_event($Purchase->id, 'notice', array('user' => $user->ID, 'kind' => 'cancelled', 'notice' => __('Marked Cancelled', 'Shopp')));
//.........這裏部分代碼省略.........
開發者ID:jonathandavis,項目名稱:shopp,代碼行數:101,代碼來源:Service.php

示例9: isequalto

 /**
  * Matches subject and value using equal to
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param mixed $subject The subject data to compare
  * @param mixed $value The value to match against
  * @param string $type The data type matching (string or float)
  * @return boolean True for a match, false for no match
  **/
 private function isequalto($subject, $value, $type = 'string')
 {
     if ('float' == $type) {
         $subject = Shopp::floatval($subject);
         $value = Shopp::floatval($value);
         return $subject != 0 && $value != 0 && $subject == $value;
     }
     if (is_array($subject)) {
         return in_array($value, $subject);
     }
     return "{$subject}" === "{$value}";
 }
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:23,代碼來源:Discounts.php

示例10: shopp_product_variant_set_saleprice

/**
 * shopp_product_variant_set_saleprice - set the sale price of a variant
 *
 * @api
 * @since 1.2
 *
 * @param int/Price $variant (required) The priceline id to set the sale price on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
 * @param bool $flag (optional default:false) true for on, false for off. Turns on or off the sale flag on the variant.  If false, price is ignored.
 * @param float $price the price to be set
 * @param string $context (optional default:variant) enforces the priceline is a 'product','variant', or 'addon'
 * @return bool/Price false on failure, true if Price saved, else the modified Price object.
 **/
function shopp_product_variant_set_saleprice($variant = false, $flag = false, $price = 0.0, $context = 'variant')
{
    $context = 'variant' == $context ? 'variation' : $context;
    $save = true;
    if (is_object($variant) && is_a($variant, 'ShoppPrice')) {
        $Price = $variant;
        $save = false;
    } else {
        if (false == $variant) {
            shopp_debug(__FUNCTION__ . " failed: Variant id required.");
            return false;
        }
        $Price = new ShoppPrice($variant);
        if (empty($Price->id) || $Price->context != $context) {
            shopp_debug(__FUNCTION__ . " failed: No such {$context} with id {$variant}.");
        }
    }
    $Price->sale = "off";
    if ($flag) {
        $Price->sale = "on";
        if (shopp_setting_enabled('tax_inclusive') && isset($Price->tax) && Shopp::str_true($Price->tax)) {
            $Product = new ShoppProduct($Price->product);
            $taxrate = shopp_taxrate(null, true, $Product);
            $price = Shopp::floatval($price / (1 + $taxrate));
        }
        $Price->saleprice = $price;
    }
    if ($save) {
        return $Price->save();
    }
    return $Price;
}
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:44,代碼來源:product.php

示例11: save

 /**
  * Handles saving updated category information from the category editor
  *
  * @author Jonathan Davis
  * @since 1.0
  * @return void
  **/
 public function save($Category)
 {
     $Shopp = Shopp::object();
     check_admin_referer('shopp-save-category');
     if (!current_user_can('shopp_categories')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     shopp_set_formsettings();
     // Save workflow setting
     if (empty($Category->meta)) {
         $Category->load_meta();
     }
     if (isset($_POST['content'])) {
         $_POST['description'] = $_POST['content'];
     }
     $Category->name = $_POST['name'];
     $Category->description = $_POST['description'];
     $Category->parent = $_POST['parent'];
     $Category->prices = array();
     // Variation price templates
     if (!empty($_POST['price']) && is_array($_POST['price'])) {
         foreach ($_POST['price'] as &$pricing) {
             $pricing['price'] = Shopp::floatval($pricing['price'], false);
             $pricing['saleprice'] = Shopp::floatval($pricing['saleprice'], false);
             $pricing['shipfee'] = Shopp::floatval($pricing['shipfee'], false);
             $pricing['dimensions'] = array_map(array('Shopp', 'floatval'), $pricing['dimensions']);
         }
     }
     $_POST['prices'] = isset($_POST['price']) ? $_POST['price'] : array();
     if (empty($_POST['specs'])) {
         $Category->specs = array();
     }
     /* @todo Move the rest of category meta inputs to [meta] inputs eventually */
     if (isset($_POST['meta']) && isset($_POST['meta']['options'])) {
         // Moves the meta options input to 'options' index for compatibility
         $_POST['options'] = $_POST['meta']['options'];
     }
     if (empty($_POST['meta']['options']) || count($_POST['meta']['options']['v']) == 1 && !isset($_POST['meta']['options']['v'][1]['options'])) {
         $_POST['options'] = $Category->options = array();
         $_POST['prices'] = $Category->prices = array();
     }
     $metaprops = array('spectemplate', 'facetedmenus', 'variations', 'pricerange', 'priceranges', 'specs', 'options', 'prices');
     $metadata = array_filter_keys($_POST, $metaprops);
     // Update existing entries
     $updates = array();
     foreach ($Category->meta as $id => $MetaObject) {
         $name = $MetaObject->name;
         if (isset($metadata[$name])) {
             $MetaObject->value = stripslashes_deep($metadata[$name]);
             $updates[] = $name;
         }
     }
     // Create any new missing meta entries
     $new = array_diff(array_keys($metadata), $updates);
     // Determine new entries from the exsting updates
     foreach ($new as $name) {
         if (!isset($metadata[$name])) {
             continue;
         }
         $Meta = new MetaObject();
         $Meta->name = $name;
         $Meta->value = stripslashes_deep($metadata[$name]);
         $Category->meta[] = $Meta;
     }
     $Category->save();
     if (!empty($_POST['deleteImages'])) {
         $deletes = array();
         if (strpos($_POST['deleteImages'], ",")) {
             $deletes = explode(',', $_POST['deleteImages']);
         } else {
             $deletes = array($_POST['deleteImages']);
         }
         $Category->delete_images($deletes);
     }
     if (!empty($_POST['images']) && is_array($_POST['images'])) {
         $Category->link_images($_POST['images']);
         $Category->save_imageorder($_POST['images']);
         if (!empty($_POST['imagedetails']) && is_array($_POST['imagedetails'])) {
             foreach ($_POST['imagedetails'] as $i => $data) {
                 $Image = new CategoryImage($data['id']);
                 $Image->title = $data['title'];
                 $Image->alt = $data['alt'];
                 $Image->save();
             }
         }
     }
     do_action_ref_array('shopp_category_saved', array($Category));
     $this->notice(Shopp::__('%s category saved.', '<strong>' . $Category->name . '</strong>'));
 }
開發者ID:forthrobot,項目名稱:inuvik,代碼行數:96,代碼來源:Categories.php

示例12: float

 /**
  * Formats tax rates to a precision beyond the currency format
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param scalar $amount An amount to convert to a float
  * @return float The float amount
  **/
 private static function float($amount)
 {
     $base = shopp_setting('base_operations');
     $format = $base['currency']['format'];
     $format['precision'] = 6;
     return Shopp::floatval($amount, true, $format);
 }
開發者ID:BlessySoftwares,項目名稱:anvelocom,代碼行數:16,代碼來源:Tax.php

示例13: refund

 public function refund()
 {
     if ('refund' != $this->form('order-action')) {
         return;
     }
     if (!current_user_can('shopp_refund')) {
         wp_die(Shopp::__('You do not have sufficient permissions to carry out this action.'));
     }
     extract($this->references);
     $user = wp_get_current_user();
     $reason = (int) $_POST['reason'];
     $amount = Shopp::floatval($_POST['amount']);
     if ($this->form('message')) {
         $Purchase->message['note'] = $this->form('message');
     }
     if (Shopp::str_true($this->form('send'))) {
         // Submit the refund request to the payment gateway
         shopp_add_order_event($Purchase->id, 'refund', array('txnid' => $Purchase->txnid, 'gateway' => $Gateway->module, 'amount' => $amount, 'reason' => $reason, 'user' => $user->ID));
     } else {
         // Force the order status to be refunded (without talking to the gateway)
         // Email a refund notice to the customer
         shopp_add_order_event($Purchase->id, 'notice', array('user' => $user->ID, 'kind' => 'refunded', 'notice' => Shopp::__('Marked Refunded')));
         // Log the refund event
         shopp_add_order_event($Purchase->id, 'refunded', array('txnid' => $Purchase->txnid, 'amount' => $amount, 'gateway' => $Gateway->module));
         // Cancel the order
         shopp_add_order_event($Purchase->id, 'voided', array('gateway' => $Gateway->module, 'txnorigin' => $Purchase->txnid, 'txnid' => current_time('timestamp')));
         $this->notice(Shopp::__('Order marked refunded.'));
     }
 }
開發者ID:msigley,項目名稱:shopp,代碼行數:29,代碼來源:Orders.php

示例14: upgrade_130

 public function upgrade_130()
 {
     global $wpdb;
     $db_version = ShoppSettings::dbversion();
     if ($db_version < 1201) {
         // 1.3 schema changes
         $this->upschema();
         // All existing sessions must be cleared and restarted, 1.3 & 1.3.6 sessions are not compatible with any prior version of Shopp
         ShoppShopping()->reset();
         $sessions_table = ShoppDatabaseObject::tablename('shopping');
         sDB::query("DELETE FROM {$sessions_table}");
         // Remove all the temporary PHP native session data from the options table
         sDB::query("DELETE FROM from {$wpdb->options} WHERE option_name LIKE '__php_session_*'");
     }
     if ($db_version < 1200) {
         $meta_table = ShoppDatabaseObject::tablename('meta');
         sDB::query("UPDATE {$meta_table} SET value='on' WHERE name='theme_templates' AND (value != '' AND value != 'off')");
         sDB::query("DELETE FROM {$meta_table} WHERE type='image' AND value LIKE '%O:10:\"ShoppError\"%'");
         // clean up garbage from legacy bug
         sDB::query("DELETE FROM {$meta_table} WHERE CONCAT('', name *1) = name AND context = 'category' AND type = 'meta'");
         // clean up bad category meta
         // Update purchase gateway values to match new prefixed class names
         $gateways = array('PayPalStandard' => 'ShoppPayPalStandard', '_2Checkout' => 'Shopp2Checkout', 'OfflinePayment' => 'ShoppOfflinePayment', 'TestMode' => 'ShoppTestMode', 'FreeOrder' => 'ShoppFreeOrder');
         foreach ($gateways as $name => $classname) {
             sDB::query("UPDATE {$purchase_table} SET gateway='{$classname}' WHERE gateway='{$name}'");
         }
         $activegateways = explode(',', shopp_setting('active_gateways'));
         foreach ($activegateways as &$setting) {
             if (false === strpos($setting, 'Shopp')) {
                 $setting = str_replace(array_keys($gateways), $gateways, $setting);
             }
         }
         shopp_set_setting('active_gateways', join(',', $activegateways));
     }
     if ($db_version < 1200 && shopp_setting_enabled('tax_inclusive')) {
         $price_table = ShoppDatabaseObject::tablename('price');
         $taxrates = shopp_setting('taxrates');
         $baseop = shopp_setting('base_operations');
         $taxtaxes = array();
         // Capture taxonomy condition tax rates
         $basetaxes = array();
         // Capture base of operations rate(s)
         foreach ($taxrates as $rate) {
             if (!($baseop['country'] == $rate['country'] || ShoppTax::ALL == $rate['country'])) {
                 continue;
             }
             if (!empty($rate['zone']) && $baseop['zone'] != $rate['zone']) {
                 continue;
             }
             if (!empty($rate['rules']) && $rate['logic'] == 'any') {
                 // Capture taxonomy conditional rates
                 foreach ($rate['rules'] as $raterule) {
                     if ('product-category' == $raterule['p']) {
                         $taxname = ProductCategory::$taxon . '::' . $raterule['v'];
                     } elseif ('product-tags' == $raterule['p']) {
                         $taxname = ProductTag::$taxon . '::' . $raterule['v'];
                     }
                     $taxtaxes[$taxname] = Shopp::floatval($rate['rate']) / 100;
                 }
             } else {
                 $basetaxes[] = Shopp::floatval($rate['rate']) / 100;
             }
         }
         // Find products by in each taxonomy termno
         $done = array();
         // Capture each set into the "done" list
         foreach ($taxtaxes as $taxterm => $taxrate) {
             list($taxonomy, $name) = explode('::', $taxterm);
             $Collection = new ProductCollection();
             $Collection->load(array('ids' => true, 'taxquery' => array(array('taxonomy' => $taxonomy, 'field' => 'name', 'terms' => $name))));
             $query = "UPDATE {$price_table} SET price=price+(price*{$taxrate}) WHERE tax='on' AND product IN (" . join(',', $Collection->products) . ")";
             sDB::query($query);
             $done = array_merge($done, $Collection->products);
         }
         // Update the rest of the prices (skipping those we've already done) with the tax rate that matches the base of operations
         $taxrate = array_sum($basetaxes);
         // Merge all the base taxes into a single rate
         $done = empty($done) ? '' : " AND product NOT IN (" . join(',', $done) . ")";
         $query = "UPDATE {$price_table} SET price=price+(price*{$taxrate}) WHERE tax='on'{$done}";
         sDB::query($query);
     }
 }
開發者ID:crunnells,項目名稱:shopp,代碼行數:82,代碼來源:Install.php

示例15: add

 /**
  * Adds a specified quantity to the line item
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function add($qty)
 {
     if ($this->type == 'Donation' && Shopp::str_true($this->donation['var'])) {
         $qty = Shopp::floatval($qty);
         $this->quantity = $this->unitprice;
     }
     $this->quantity($this->quantity + $qty);
 }
開發者ID:borkweb,項目名稱:shopp,代碼行數:16,代碼來源:Item.php


注:本文中的Shopp::floatval方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。