当前位置: 首页>>代码示例>>PHP>>正文


PHP zen_get_prid函数代码示例

本文整理汇总了PHP中zen_get_prid函数的典型用法代码示例。如果您正苦于以下问题:PHP zen_get_prid函数的具体用法?PHP zen_get_prid怎么用?PHP zen_get_prid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zen_get_prid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _calcAddPoint

 function _calcAddPoint()
 {
     global $db, $order;
     require_once DIR_FS_CATALOG . $GLOBALS['point_base']->dir . 'classes/class.point.php';
     $point =& new point($_SESSION['customer_id']);
     $this->amount = 0;
     $this->point = 0;
     if (MODULE_POINT_PRODUCTSRATE_STATUS == 'true') {
         foreach ($order->products as $fields) {
             $products_id = zen_get_prid($fields['id']);
             $products_pointrate = $GLOBALS['point_productsrate']->getPointRate($products_id);
             if ($products_pointrate !== false) {
                 $this->point += (int) ($fields['final_price'] * $fields['qty'] * $products_pointrate / 100);
             } else {
                 $this->amount += $fields['final_price'] * $fields['qty'];
             }
         }
     } else {
         foreach ($order->products as $fields) {
             $this->amount += $fields['final_price'] * $fields['qty'];
         }
     }
     if (MODULE_POINT_GROUPRATE_STATUS == 'true') {
         $query = "\r\n          select\r\n            customers_group_pricing\r\n          from\r\n            " . TABLE_CUSTOMERS . "\r\n          where\r\n            customers_id = :customersID\r\n          ;";
         $query = $db->bindVars($query, ':customersID', $_SESSION['customer_id'], 'integer');
         $result = $db->Execute($query);
         if ($result->RecordCount() > 0) {
             $group_id = $result->fields['customers_group_pricing'];
             $group_pointrate = $GLOBALS['point_grouprate']->getPointRate($group_id);
             if ($group_pointrate !== false) {
                 $this->rate = $group_pointrate;
             }
         }
     }
     if (MODULE_POINT_CUSTOMERSRATE_STATUS == 'true') {
         $customers_pointrate = $GLOBALS['point_customersrate']->getPointRate($_SESSION['customer_id']);
         if ($customers_pointrate !== false) {
             $this->rate = $customers_pointrate;
         }
     }
     $this->point += (int) ($this->amount * $this->rate / 100);
     $deduction = 0;
     if (is_object($GLOBALS['ot_coupon'])) {
         $deduction += $GLOBALS['ot_coupon']->deduction;
     }
     if (is_object($GLOBALS['cot_gv'])) {
         $deduction += $GLOBALS['cot_gv']->deduction;
     }
     if (is_object($GLOBALS['ot_subpoint'])) {
         $deduction += $GLOBALS['ot_subpoint']->deduction;
     }
     if (is_object($GLOBALS['ot_group_pricing'])) {
         $deduction += $GLOBALS['ot_group_pricing']->deduction;
     }
     $this->point -= ceil($deduction * $this->rate / 100);
 }
开发者ID:homework-bazaar,项目名称:zencart-sugu,代码行数:56,代码来源:ot_addpoint.php

示例2: getProductObject

 function getProductObject($pProductsMixed)
 {
     $productsId = zen_get_prid($pProductsMixed);
     if (BitBase::verifyId($productsId)) {
         if (!isset($this->mProductObjects[$productsId])) {
             if ($this->mProductObjects[$productsId] = bc_get_commerce_product($productsId)) {
                 $ret =& $this->mProductObjects[$productsId];
             }
         }
     }
     return $this->mProductObjects[$productsId];
 }
开发者ID:bitweaver,项目名称:commerce,代码行数:12,代码来源:CommerceOrderBase.php

示例3: pwas_get_products_stock

function pwas_get_products_stock($products_id, $attributes = '')
{
    global $db;
    $products_id = zen_get_prid($products_id);
    // get product level stock quantity
    $stock_query = "select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'";
    // check if there attributes for this product
    if (is_array($attributes) and sizeof($attributes) > 0) {
        // check if any attribute stock values have been set for the product
        // (only of there is will we continue, otherwise we'll use product level data)
        $attribute_stock = $db->Execute("select stock_id from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " where products_id = '" . (int) $products_id . "'");
        if ($attribute_stock->RecordCount() > 0) {
            // prepare to search for details for the particular attribute combination passed as a parameter
            if (sizeof($attributes) > 1) {
                if (isset($attributes[0]['value_id'])) {
                    $ary = array();
                    for ($i = 0; $i < count($attributes); $i++) {
                        $ary[] = $attributes[$i]['value_id'];
                    }
                } else {
                    $ary = $attributes;
                }
                $first_search = 'where options_values_id in ("' . implode('","', $ary) . '")';
            } else {
                if (isset($attributes[0]['value_id'])) {
                    $first_search = 'where options_values_id="' . $attributes[0]['value_id'] . '"';
                } else {
                    foreach ($attributes as $attribute) {
                        $first_search = 'where options_values_id="' . $attribute . '"';
                    }
                }
            }
            // obtain the attribute ids
            $query = 'select products_attributes_id from ' . TABLE_PRODUCTS_ATTRIBUTES . ' ' . $first_search . ' and products_id="' . $products_id . '" order by products_attributes_id';
            $attributes_new = $db->Execute($query);
            while (!$attributes_new->EOF) {
                $stock_attributes[] = $attributes_new->fields['products_attributes_id'];
                $attributes_new->MoveNext();
            }
            if (sizeof($stock_attributes) > 1) {
                $stock_attributes = implode(',', $stock_attributes);
            } else {
                $stock_attributes = $stock_attributes[0];
            }
            // create the query to find attribute stock
            $stock_query = 'select quantity as products_quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id = "' . (int) $products_id . '" and stock_attributes="' . $stock_attributes . '"';
        }
    }
    // get the stock value for the product or attribute combination
    $stock_values = $db->Execute($stock_query);
    return $stock_values->fields['products_quantity'];
}
开发者ID:homework-bazaar,项目名称:zencart-sugu,代码行数:52,代码来源:functions.php

示例4: create_add_products

 function create_add_products($pOrdersId, $zf_mode = false)
 {
     global $gBitDb, $gBitUser, $currencies, $order_total_modules, $order_totals;
     $this->StartTrans();
     // initialized for the email confirmation
     $this->products_ordered_html = '';
     // lowstock email report
     $this->email_low_stock = '';
     foreach (array_keys($this->contents) as $productsKey) {
         // Stock Update - Joao Correia
         if (STOCK_LIMITED == 'true') {
             if (DOWNLOAD_ENABLED == 'true') {
                 $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename\n\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PRODUCTS . " p\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON(p.`products_id`=pom.`products_id`)\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON (pa.`products_options_values_id`=pom.`products_options_values_id`)\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON(pa.`products_attributes_id`=pad.`products_attributes_id`)\n\t\t\t\t\t\t\t\t\t\tWHERE p.`products_id` = ?";
                 $bindVars = array(zen_get_prid($this->contents[$productsKey]['id']));
                 // Will work with only one option for downloadable products
                 // otherwise, we have to build the query dynamically with a loop
                 $products_attributes = $this->contents[$productsKey]['attributes'];
                 if (is_array($products_attributes)) {
                     $stock_query_raw .= " AND pa.`products_options_id` = ? AND pa.`products_options_values_id` = ?";
                     $bindVars[] = zen_get_options_id($products_attributes[0]['option_id']);
                     $bindVars[] = $products_attributes[0]['value_id'];
                 }
                 $stockValues = $gBitDb->query($stock_query_raw, $bindVars);
             } else {
                 $stockValues = $gBitDb->getRow("select `products_quantity` from " . TABLE_PRODUCTS . " where `products_id` = ?", array(zen_get_prid($this->contents[$productsKey]['id'])));
             }
             if ($stock_values && $stock_values->RecordCount() > 0) {
                 // do not decrement quantities if products_attributes_filename exists
                 if (DOWNLOAD_ENABLED != 'true' || !empty($stockValues['products_attributes_filename'])) {
                     $stock_left = $stockValues['products_quantity'] - $this->contents[$productsKey]['products_quantity'];
                     $this->contents[$productsKey]['stock_reduce'] = $this->contents[$productsKey]['products_quantity'];
                 } else {
                     $stock_left = $stockValues['products_quantity'];
                 }
                 //				$this->contents[$productsKey]['stock_value'] = $stockValues['products_quantity'];
                 $gBitDb->Execute("update " . TABLE_PRODUCTS . " set `products_quantity` = '" . $stock_left . "' where `products_id` = '" . zen_get_prid($this->contents[$productsKey]['id']) . "'");
                 //				if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
                 if ($stock_left < 1) {
                     // only set status to off when not displaying sold out
                     if (SHOW_PRODUCTS_SOLD_OUT == '0') {
                         $gBitDb->Execute("update " . TABLE_PRODUCTS . " set `products_status` = '0' where `products_id` = '" . zen_get_prid($this->contents[$productsKey]['id']) . "'");
                     }
                 }
                 // for low stock email
                 if ($stock_left <= STOCK_REORDER_LEVEL) {
                     // WebMakers.com Added: add to low stock email
                     $this->email_low_stock .= 'ID# ' . zen_get_prid($this->contents[$productsKey]['id']) . "\t\t" . $this->contents[$productsKey]['model'] . "\t\t" . $this->contents[$productsKey]['name'] . "\t\t" . ' Qty Left: ' . $stock_left . "\n";
                 }
             }
         }
         // Update products_ordered (for bestsellers list)
         $gBitDb->Execute("update " . TABLE_PRODUCTS . " set `products_ordered` = `products_ordered` + " . sprintf('%f', $this->contents[$productsKey]['products_quantity']) . " where `products_id` = '" . zen_get_prid($this->contents[$productsKey]['id']) . "'");
         $sql_data_array = array('orders_id' => $pOrdersId, 'products_id' => zen_get_prid($this->contents[$productsKey]['id']), 'products_model' => $this->contents[$productsKey]['model'], 'products_name' => $this->contents[$productsKey]['name'], 'products_price' => $this->contents[$productsKey]['price'], 'products_cogs' => $this->contents[$productsKey]['products_cogs'], 'products_wholesale' => $this->contents[$productsKey]['products_wholesale'], 'products_commission' => $this->contents[$productsKey]['commission'], 'final_price' => $this->contents[$productsKey]['final_price'], 'onetime_charges' => $this->contents[$productsKey]['onetime_charges'], 'products_tax' => $this->contents[$productsKey]['tax'], 'products_quantity' => $this->contents[$productsKey]['products_quantity'], 'products_priced_by_attribute' => $this->contents[$productsKey]['products_priced_by_attribute'], 'product_is_free' => $this->contents[$productsKey]['product_is_free'], 'products_discount_type' => $this->contents[$productsKey]['products_discount_type'], 'products_discount_type_from' => $this->contents[$productsKey]['products_discount_type_from']);
         $gBitDb->associateInsert(TABLE_ORDERS_PRODUCTS, $sql_data_array);
         $this->contents[$productsKey]['orders_products_id'] = zen_db_insert_id(TABLE_ORDERS_PRODUCTS, 'orders_products_id');
         $order_total_modules->update_credit_account($productsKey);
         //ICW ADDED FOR CREDIT CLASS SYSTEM
         if (!empty($this->contents[$productsKey]['purchase_group_id'])) {
             $gBitUser->addUserToGroup($gBitUser->mUserId, $this->contents[$productsKey]['purchase_group_id']);
         }
         //------insert customer choosen option to order--------
         $attributes_exist = '0';
         $this->products_ordered_attributes = '';
         if (!empty($this->contents[$productsKey]['attributes'])) {
             $attributes_exist = '1';
             foreach (array_keys($this->contents[$productsKey]['attributes']) as $j) {
                 $optionValues = zen_get_option_value((int) $this->contents[$productsKey]['attributes'][$j]['option_id'], (int) $this->contents[$productsKey]['attributes'][$j]['value_id']);
                 if (!empty($optionValues['purchase_group_id'])) {
                     $gBitUser->addUserToGroup($gBitUser->mUserId, $optionValues['purchase_group_id']);
                 }
                 if (!empty($optionValues['products_options_id'])) {
                     //clr 030714 update insert query.	changing to use values form $order->contents for products_options_values.
                     $sql_data_array = array('orders_id' => $pOrdersId, 'orders_products_id' => $this->contents[$productsKey]['orders_products_id'], 'products_options' => $optionValues['products_options_name'], 'products_options_values' => $this->contents[$productsKey]['attributes'][$j]['value'], 'options_values_price' => $optionValues['options_values_price'], 'options_values_cogs' => $optionValues['options_values_cogs'], 'options_values_wholesale' => $optionValues['options_values_wholesale'], 'price_prefix' => $optionValues['price_prefix'], 'product_attribute_is_free' => $optionValues['product_attribute_is_free'], 'products_attributes_wt' => $optionValues['products_attributes_wt'], 'products_attributes_wt_pfix' => $optionValues['products_attributes_wt_pfix'], 'attributes_discounted' => (int) $optionValues['attributes_discounted'], 'attributes_price_base_inc' => (int) $optionValues['attributes_price_base_inc'], 'attributes_price_onetime' => $optionValues['attributes_price_onetime'], 'attributes_price_factor' => $optionValues['attributes_price_factor'], 'attributes_pf_offset' => $optionValues['attributes_pf_offset'], 'attributes_pf_onetime' => $optionValues['attributes_pf_onetime'], 'attributes_pf_onetime_offset' => $optionValues['attributes_pf_onetime_offset'], 'attributes_qty_prices' => $optionValues['attributes_qty_prices'], 'attributes_qty_prices_onetime' => $optionValues['attributes_qty_prices_onetime'], 'attributes_price_words' => $optionValues['attributes_price_words'], 'attributes_price_words_free' => $optionValues['attributes_price_words_free'], 'attributes_price_letters' => $optionValues['attributes_price_letters'], 'attributes_price_letters_free' => $optionValues['attributes_price_letters_free'], 'products_options_id' => $optionValues['products_options_id'], 'products_options_values_id' => $optionValues['products_options_values_id']);
                     $gBitDb->associateInsert(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
                 }
                 if (DOWNLOAD_ENABLED == 'true' && isset($optionValues['products_attributes_filename']) && zen_not_null($optionValues['products_attributes_filename'])) {
                     $sql_data_array = array('orders_id' => $pOrdersId, 'orders_products_id' => $this->contents[$productsKey]['orders_products_id'], 'orders_products_filename' => $optionValues['products_attributes_filename'], 'download_maxdays' => $optionValues['products_attributes_maxdays'], 'download_count' => $optionValues['products_attributes_maxcount']);
                     $gBitDb->associateInsert(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
                 }
                 $this->products_ordered_attributes .= "\n\t" . $optionValues['products_options_name'] . ' ' . zen_decode_specialchars($this->contents[$productsKey]['attributes'][$j]['value']);
             }
         }
         //------insert customer choosen option eof ----
         $this->total_weight += $this->contents[$productsKey]['products_quantity'] * $this->contents[$productsKey]['weight'];
         //			$this->total_tax += zen_calculate_tax($total_products_price, $products_tax) * $this->contents[$productsKey]['products_quantity'];
         //			$this->total_cost += $total_products_price;
         $this->products_ordered_html .= '<tr>' . '<td class="product-details alignright" valign="top" width="30">' . $this->contents[$productsKey]['products_quantity'] . '&nbsp;x</td>' . '<td class="product-details" valign="top">' . $this->contents[$productsKey]['name'] . ($this->contents[$productsKey]['model'] != '' ? ' (' . $this->contents[$productsKey]['model'] . ') ' : '') . '<span style="white-space:nowrap;"><small><em> ' . $this->products_ordered_attributes . '</em></small></span></td>' . '<td class="product-details-num alignright" valign="top">' . $currencies->display_price($this->contents[$productsKey]['final_price'], $this->contents[$productsKey]['tax'], $this->contents[$productsKey]['products_quantity']) . ($this->contents[$productsKey]['onetime_charges'] != 0 ? '</td></tr><tr><td class="product-details">' . TEXT_ONETIME_CHARGES_EMAIL . '</td>' . '<td>' . $currencies->display_price($this->contents[$productsKey]['onetime_charges'], $this->contents[$productsKey]['tax'], 1) : '') . '</td></tr>';
     }
     $order_total_modules->apply_credit();
     //ICW ADDED FOR CREDIT CLASS SYSTEM
     $this->CompleteTrans();
 }
开发者ID:bitweaver,项目名称:commerce,代码行数:92,代码来源:CommerceOrder.php

示例5: in_cart_check

 /**
  * Method to calculate the number of items in a cart based on an abitrary property
  *
  * $check_what is the fieldname example: 'products_is_free'
  * $check_value is the value being tested for - default is 1
  * Syntax: $_SESSION['cart']->in_cart_check('product_is_free','1');
  *
  * @param string product field to check
  * @param mixed value to check for
  * @return integer number of items matching restraint
  */
 function in_cart_check($check_what, $check_value = '1')
 {
     global $db;
     // if nothing is in cart return 0
     if (!is_array($this->contents)) {
         return 0;
     }
     // compute total quantity for field
     $in_cart_check_qty = 0;
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $testing_id = zen_get_prid($products_id);
         // check if field it true
         $product_check = $db->Execute("select " . $check_what . " as check_it from " . TABLE_PRODUCTS . " where products_id='" . $testing_id . "' limit 1");
         if ($product_check->fields['check_it'] == $check_value) {
             $in_cart_check_qty += $this->contents[$products_id]['qty'];
         }
     }
     return $in_cart_check_qty;
 }
开发者ID:jeking928,项目名称:Dual-Pricing-2.1.6,代码行数:31,代码来源:shopping_cart.php

示例6: zen_get_products_stock

/**
 * Return a product's stock count.
 *
 * @param int The product id of the product who's stock we want
*/
function zen_get_products_stock($products_id)
{
    global $db;
    $products_id = zen_get_prid($products_id);
    $stock_query = "select products_quantity\r\n                    from " . TABLE_PRODUCTS . "\r\n                    where products_id = '" . (int) $products_id . "'";
    $stock_values = $db->Execute($stock_query);
    return $stock_values->fields['products_quantity'];
}
开发者ID:bobjacobsen,项目名称:EventTools,代码行数:13,代码来源:functions_lookups.php

示例7: zen_get_products_stock

function zen_get_products_stock($products_id, $attributes = null, $dupTest = null)
{
    global $db;
    $products_id = zen_get_prid($products_id);
    // Need to evaluate if product is SBA tracked in case the page is posted without the attributes as a separate check.
    if ($products_id && (!is_array($attributes) && !zen_not_null($attributes))) {
        //For products without associated attributes, get product level stock quantity
        $stock_query = "select products_quantity \n                      from " . TABLE_PRODUCTS . " \n                      where products_id = :products_id:";
        $stock_query = $db->bindVars($stock_query, ':products_id:', $products_id, 'integer');
        $stock_values = $db->Execute($stock_query);
        return $stock_values->fields['products_quantity'];
    } elseif (is_array($attributes) && sizeof($attributes) > 0) {
        //For products with associated attributes, to do the following:
        //	1. Check if the attribute has been added to the SBA Stock Page.
        //	2. Check if the attribute(s) are listed in seperate rows or are combined into a single row.
        // mc12345678 - The following seems like it could be compressed more/do less searches.  Now that this seems to work, there is some code that can be compressed.
        /* mc12345678 Comment about the $attribute_stock test is really to see if the product is tracked by SBA. */
        // check if any attribute stock values have been set for the product in the SBA table, if not do the else part
        if (zen_product_is_sba($products_id)) {
            // prepare to search for details for the particular attribute combination passed as a parameter
            $stock_attributes_list = array();
            $stock_attributes = '';
            $stock_attributes_list = zen_get_sba_attribute_ids($products_id, $attributes, 'products');
            if (sizeof($stock_attributes_list) == 1 && !$dupTest) {
                // 		  	echo '<br />Single Attribute <br />';
                $stock_attributes = $stock_attributes_list[0];
                // create the query to find single attribute stock
                $stock_query = 'select stock_id, quantity as products_quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id = :products_id: and stock_attributes=:stock_attributes:';
                $stock_query = $db->bindVars($stock_query, ':products_id:', $products_id, 'integer');
                $stock_query = $db->bindVars($stock_query, ':stock_attributes:', $stock_attributes, 'passthru');
                $stock_values = $db->Execute($stock_query);
                // return the stock qty for the attribute
                if (!$stock_values->EOF) {
                    return $stock_values->fields['products_quantity'];
                } else {
                    return false;
                }
            } elseif (sizeof($stock_attributes_list) > 1) {
                // mc12345678 multiple attributes are associated with the product
                //   question is how these relate to the SBA variant.
                // 			echo '<br />Multiple attributes <br />';
                $stockResult = null;
                //This part checks for "attribute combinations" in the SBA table. (Multiple attributes per Stock ID Row, Multiple Attribute types in stock_attributes Field  i.e, 123,321,234)
                $TMPstock_attributes = implode(',', $stock_attributes_list);
                // create the query to find attribute stock
                $stock_query = 'select stock_id, quantity as products_quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id = :products_id: and stock_attributes like :TMPstock_attributes:';
                $stock_query = $db->bindVars($stock_query, ':products_id:', $products_id, 'integer');
                $stock_query = $db->bindVars($stock_query, ':TMPstock_attributes:', $TMPstock_attributes, 'string');
                // get the stock value for the combination
                $stock_values = $db->Execute($stock_query);
                $stockResult = $stock_values->fields['products_quantity'];
                if ($dupTest) {
                    //return the stock for "attribute combinations" with a flag
                    if ($stockResult > 0) {
                        return 'true';
                    }
                    return 'false';
                } elseif (!$stock_values->EOF && $stock_values->RecordCount() == 1) {
                    //return the stock for "attribute combinations"
                    return $stockResult;
                } else {
                    //This part is for attributes that are all listed separately in the SBA table for the product
                    $stockResult = null;
                    $returnedStock = null;
                    $i = 0;
                    $notAccounted = false;
                    foreach ($stock_attributes_list as $eachAttribute) {
                        // create the query to find attribute stock
                        //echo '<br />Multiple Attributes selected (one attribute type per product)<br />';
                        $stock_query = 'select quantity as products_quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id = :products_id: and stock_attributes= :eachAttribute:';
                        $stock_query = $db->bindVars($stock_query, ':products_id:', $products_id, 'integer');
                        $stock_query = $db->bindVars($stock_query, ':eachAttribute:', $eachAttribute, 'passthru');
                        // get the stock value for the combination
                        $stock_values = $db->Execute($stock_query);
                        $stockResult = $stock_values->fields['products_quantity'];
                        if ($stockResult->EOF) {
                            $notAccounted = true;
                        }
                        //special test to account for qty when all attributes are listed seperetly
                        if (!zen_not_null($returnedStock) && $i == 0) {
                            //set initial value
                            if ($stock_values->EOF) {
                                $returnedStock = 0;
                            } else {
                                $returnedStock = $stockResult;
                            }
                        } elseif ($returnedStock > $stockResult) {
                            //update for each attribute, if qty is lower than the previous one
                            $returnedStock = $stockResult;
                        }
                        // end if first stock item of attribute
                        $i++;
                    }
                    // end for each attribute.
                    if ($notAccounted) {
                        return false;
                    } else {
                        return $returnedStock;
                    }
                }
//.........这里部分代码省略.........
开发者ID:badarac,项目名称:stock_by_attribute_1.5.4,代码行数:101,代码来源:functions_lookups.php

示例8: zen_redirect

    $messageStack->add_session('checkout_payment', ERROR_NO_PAYMENT_MODULE_SELECTED, 'error');
}
if (is_array($payment_modules->modules)) {
    $payment_modules->pre_confirmation_check();
}
if ($messageStack->size('checkout_payment') > 0) {
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
//echo $messageStack->size('checkout_payment');
//die('here');
// Stock Check
$flagAnyOutOfStock = false;
$stock_check = array();
if (STOCK_CHECK == 'true') {
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
        if ($stock_check[$i] = zen_check_stock($order->products[$i]['id'], $product_in_order[zen_get_prid($order->products[$i]['id'])])) {
            $flagAnyOutOfStock = true;
        }
    }
    // Out of Stock
    if (STOCK_ALLOW_CHECKOUT != 'true' && $flagAnyOutOfStock == true) {
        zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
    }
}
// update customers_referral with $_SESSION['gv_id']
if ($_SESSION['cc_id']) {
    $discount_coupon_query = "SELECT coupon_code\r\n                            FROM " . TABLE_COUPONS . "\r\n                            WHERE coupon_id = :couponID";
    $discount_coupon_query = $db->bindVars($discount_coupon_query, ':couponID', $_SESSION['cc_id'], 'integer');
    $discount_coupon = $db->Execute($discount_coupon_query);
    $customers_referral_query = "SELECT customers_referral\r\n                               FROM " . TABLE_CUSTOMERS . "\r\n                               WHERE customers_id = :customersID";
    $customers_referral_query = $db->bindVars($customers_referral_query, ':customersID', $_SESSION['customer_id'], 'integer');
开发者ID:ygeneration666,项目名称:ec,代码行数:31,代码来源:header_php.php

示例9: create_add_products

 function create_add_products($zf_insert_id, $zf_mode = false)
 {
     global $db, $currencies, $order_total_modules, $order_totals, $zco_notifier;
     // initialized for the email confirmation
     $this->products_ordered = '';
     $this->products_ordered_html = '';
     $this->subtotal = 0;
     $this->total_tax = 0;
     // lowstock email report
     $this->email_low_stock = '';
     for ($i = 0, $n = sizeof($this->products); $i < $n; $i++) {
         $custom_insertable_text = '';
         // Stock Update - Joao Correia
         if (STOCK_LIMITED == 'true') {
             if (DOWNLOAD_ENABLED == 'true') {
                 $stock_query_raw = "select p.products_quantity, pad.products_attributes_filename, p.product_is_always_free_shipping\n\n                              from " . TABLE_PRODUCTS . " p\n\n                              left join " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\n                               on p.products_id=pa.products_id\n\n                              left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n\n                               on pa.products_attributes_id=pad.products_attributes_id\n\n                              WHERE p.products_id = '" . zen_get_prid($this->products[$i]['id']) . "'";
                 // Will work with only one option for downloadable products
                 // otherwise, we have to build the query dynamically with a loop
                 $products_attributes = $this->products[$i]['attributes'];
                 if (is_array($products_attributes)) {
                     $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
                 }
                 $stock_values = $db->Execute($stock_query_raw);
             } else {
                 $stock_values = $db->Execute("select * from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
             }
             $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_BEGIN');
             if ($stock_values->RecordCount() > 0) {
                 // do not decrement quantities if products_attributes_filename exists
                 if (DOWNLOAD_ENABLED != 'true' || $stock_values->fields['product_is_always_free_shipping'] == 2 || !$stock_values->fields['products_attributes_filename']) {
                     $stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
                     $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
                 } else {
                     $stock_left = $stock_values->fields['products_quantity'];
                 }
                 //            $this->products[$i]['stock_value'] = $stock_values->fields['products_quantity'];
                 $db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
                 if (defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK')) {
                     // kuroi: Begin Stock by Attributes additions
                     // added to update quantities of products with attributes
                     $attribute_search = array();
                     $attribute_stock_left = STOCK_REORDER_LEVEL + 1;
                     // kuroi: prevent false low stock triggers
                     if (isset($this->products[$i]['attributes']) and sizeof($this->products[$i]['attributes']) > 0) {
                         foreach ($this->products[$i]['attributes'] as $attributes) {
                             $attribute_search[] = $attributes['value_id'];
                         }
                         if (sizeof($attribute_search) > 1) {
                             $attribute_search = 'where options_values_id in ("' . implode('","', $attribute_search) . '")';
                         } else {
                             $attribute_search = 'where options_values_id="' . $attribute_search[0] . '"';
                         }
                         $query = 'select products_attributes_id from ' . TABLE_PRODUCTS_ATTRIBUTES . ' ' . $attribute_search . ' and products_id="' . zen_get_prid($this->products[$i]['id']) . '" order by products_attributes_id';
                         $attributes = $db->Execute($query);
                         $stock_attributes_search = array();
                         while (!$attributes->EOF) {
                             $stock_attributes_search[] = $attributes->fields['products_attributes_id'];
                             $attributes->MoveNext();
                         }
                         if (sizeof($stock_attributes_search) > 1) {
                             $stock_attributes_search = implode(',', $stock_attributes_search);
                         } else {
                             foreach ($stock_attributes_search as $attribute_search) {
                                 $stock_attributes_search1 = $attribute_search;
                             }
                             $stock_attributes_search = $stock_attributes_search1;
                         }
                         $get_quantity_query = 'select quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id="' . zen_get_prid($this->products[$i]['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
                         $attribute_stock_available = $db->Execute($get_quantity_query);
                         $attribute_stock_left = $attribute_stock_available->fields['quantity'] - $this->products[$i]['qty'];
                         $attribute_update_query = 'update ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' set quantity=' . $attribute_stock_left . ' where products_id="' . zen_get_prid($this->products[$i]['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
                         $db->Execute($attribute_update_query);
                     }
                     // kuroi: End Stock by Attribute additions
                 }
                 if ($stock_left <= 0) {
                     // only set status to off when not displaying sold out
                     if (SHOW_PRODUCTS_SOLD_OUT == '0') {
                         $db->Execute("update " . TABLE_PRODUCTS . " set products_status = 0 where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
                     }
                 }
                 // for low stock email
                 if ($stock_left <= STOCK_REORDER_LEVEL) {
                     // WebMakers.com Added: add to low stock email
                     $this->email_low_stock .= 'ID# ' . zen_get_prid($this->products[$i]['id']) . ', ' . $this->products[$i]['model'] . ', ' . $this->products[$i]['name'] . ', ' . 'Stock: ' . $stock_left . "\n\n";
                     // kuroi: trigger and details for attribute low stock email
                 } elseif ($attribute_stock_left <= STOCK_REORDER_LEVEL) {
                     $this->email_low_stock .= 'ID# ' . zen_get_prid($this->products[$i]['id']) . ', ' . $this->products[$i]['model'] . ', ' . $this->products[$i]['name'] . ', ';
                     foreach ($this->products[$i]['attributes'] as $attributes) {
                         $this->email_low_stock .= $attributes['option'] . ': ' . $attributes['value'] . ', ';
                     }
                     $this->email_low_stock .= 'Stock: ' . $attribute_stock_left . "\n\n";
                 }
             }
         }
         // Update products_ordered (for bestsellers list)
         //    $db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . zen_get_prid($order->products[$i]['id']) . "'");
         $db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%f', $this->products[$i]['qty']) . " where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
         $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END');
         $products_name = $this->products[$i]['name'];
//.........这里部分代码省略.........
开发者ID:andychang88,项目名称:daddy-store.com,代码行数:101,代码来源:order.php

示例10: htmlspecialchars

             $attr_value = htmlspecialchars($products[$i]['attributes_values'][$option], ENT_COMPAT, CHARSET, TRUE);
         } else {
             $attributeHiddenField .= zen_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
             $attr_value = $attributes_values->fields['products_options_values_name'];
         }
         $attrArray[$option]['products_options_name'] = $attributes_values->fields['products_options_name'];
         $attrArray[$option]['options_values_id'] = $value;
         $attrArray[$option]['products_options_values_name'] = $attr_value;
         $attrArray[$option]['options_values_price'] = $attributes_values->fields['options_values_price'];
         $attrArray[$option]['price_prefix'] = $attributes_values->fields['price_prefix'];
     }
 }
 //end foreach [attributes]
 if (STOCK_CHECK == 'true') {
     $product_in_cart[zen_get_prid($products[$i]['id'])] += $products[$i]['quantity'];
     $flagStockCheck = zen_check_stock($products[$i]['id'], $product_in_cart[zen_get_prid($products[$i]['id'])]);
     if ($flagStockCheck == true) {
         $flagAnyOutOfStock = true;
     }
 }
 $linkProductsImage = zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']);
 $linkProductsName = zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']);
 $productsImage = IMAGE_SHOPPING_CART_STATUS == 1 ? zen_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT) : '';
 $show_products_quantity_max = zen_get_products_quantity_order_max($products[$i]['id']);
 $showFixedQuantity = ($show_products_quantity_max == 1 or zen_get_products_qty_box_status($products[$i]['id']) == 0) ? true : false;
 //  $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('products_id[]', $products[$i]['id']) . zen_draw_hidden_field('cart_quantity[]', 1);
 //  $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('cart_quantity[]', 1);
 $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('cart_quantity[]', $products[$i]['quantity']);
 $showMinUnits = zen_get_products_quantity_min_units_display($products[$i]['id']);
 $quantityField = zen_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"');
 $ppe = $products[$i]['final_price'];
开发者ID:ygeneration666,项目名称:ec,代码行数:31,代码来源:header_php.php

示例11: zen_get_products_quantity_order_max

     $_POST['cart_quantity'][$i] = 0;
     continue;
 }
 if (in_array($_POST['products_id'][$i], is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()) or $_POST['cart_quantity'][$i] == 0) {
     $_SESSION['cart']->remove($_POST['products_id'][$i]);
 } else {
     if ((PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_dropdown' || PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_radioset') && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '1' || PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '2')) {
         /* Breakdown the attributes into individual attributes to then be able to 
          * feed them into the applicable section(s).
          * 
          */
     }
     $add_max = zen_get_products_quantity_order_max($_POST['products_id'][$i]);
     // maximum allowed
     $query = 'select stock_id from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id = :products_id:';
     $query = $db->bindVars($query, ':products_id:', zen_get_prid($_POST['products_id'][$i]), 'integer');
     $stock_id = $db->Execute($query, false, false, 0, true);
     if ((PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_dropdown' || PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_radioset') && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '1' || PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '2')) {
         /* Breakdown the attributes into individual attributes to then be able to 
          * feed them into the applicable section(s).
          * 
          */
     }
     $attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : null;
     if ($stock_id->RecordCount()) {
         $productIsSBA[$i] = true;
     } else {
         $productIsSBA[$i] = false;
     }
     if (!$productIsSBA[$i]) {
         if ((PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_dropdown' || PRODINFO_ATTRIBUTE_PLUGIN_MULTI == 'single_radioset') && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '1' || PRODINFO_ATTRIBUTE_DYNAMIC_STATUS == '2')) {
开发者ID:badarac,项目名称:stock_by_attribute_1.5.4,代码行数:31,代码来源:stock_by_attributes.php

示例12: confirmation

 function confirmation()
 {
     global $cartID, $pagamastardeOrderGeneratedInConfirmation, $pagamastardeCartIDinConfirmation, $customer_id, $languages_id, $order, $order_total_modules, $db;
     $insert_order = false;
     if (empty($pagamastardeOrderGeneratedInConfirmation)) {
         $insert_order = true;
     }
     // start - proceso estandar para generar el pedido
     //
     // Si el pedido contiene campos extra (NIF, ..)
     // habria que personalizar donde corresponda, de forma similar a la personalizacion
     // que se haya hecho en checkout_process.php
     // La informacion de la sesion activa del usuario se guarda temporalmente en el campo cc_owner
     // De esta forma se evita la creacion de una tabla adicional para seguimiento de la sesion
     if ($insert_order == true) {
         $order_totals = array();
         if (is_array($order_total_modules->modules)) {
             reset($order_total_modules->modules);
             while (list(, $value) = each($order_total_modules->modules)) {
                 $class = substr($value, 0, strrpos($value, '.'));
                 if ($GLOBALS[$class]->enabled) {
                     for ($i = 0, $n = sizeof($GLOBALS[$class]->output); $i < $n; $i++) {
                         if (zen_not_null($GLOBALS[$class]->output[$i]['title']) && zen_not_null($GLOBALS[$class]->output[$i]['text'])) {
                             $order_totals[] = array('code' => $GLOBALS[$class]->code, 'title' => $GLOBALS[$class]->output[$i]['title'], 'text' => $GLOBALS[$class]->output[$i]['text'], 'value' => $GLOBALS[$class]->output[$i]['value'], 'sort_order' => $GLOBALS[$class]->sort_order);
                         }
                     }
                 }
             }
         }
         //customer id not correctly stored, this line fixes it.
         $customer_id = $_SESSION['customer_id'];
         $sql_data_array = array('customers_id' => $customer_id, 'order_total' => $order->info['total'], 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'], 'customers_street_address' => $order->customer['street_address'], 'customers_suburb' => $order->customer['suburb'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_suburb' => $order->delivery['suburb'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_suburb' => $order->billing['suburb'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => 'getfinancing', 'payment_module_code' => 'getfinancing', 'cc_type' => $order->info['cc_type'], 'cc_owner' => zen_session_id(), 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value'], 'shipping_method' => $order->info['shipping_method'], 'shipping_module_code' => $order->info['shipping_module_code']);
         zen_db_perform(TABLE_GETFINANCING_ORDERS, $sql_data_array);
         $insert_id = $db->insert_ID();
         //the $_GLOBAL seems to fail. applying patch:
         $sql_data_array = array('orders_id' => $insert_id, 'title' => 'Total:', 'text' => $order->info['total'], 'value' => $order->info['total'], 'class' => 'ot_total', 'sort_order' => 999);
         zen_db_perform(TABLE_GETFINANCING_ORDERS_TOTAL, $sql_data_array);
         for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
             $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']);
             zen_db_perform(TABLE_GETFINANCING_ORDERS_TOTAL, $sql_data_array);
         }
         for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
             $sql_data_array = array('orders_id' => $insert_id, 'products_id' => zen_get_prid($order->products[$i]['id']), 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty']);
             zen_db_perform(TABLE_GETFINANCING_ORDERS_PRODUCTS, $sql_data_array);
             $order_products_id = $db->insert_ID();
             $attributes_exist = '0';
             if (isset($order->products[$i]['attributes'])) {
                 $attributes_exist = '1';
                 for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                     if (DOWNLOAD_ENABLED == 'true') {
                         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename\n                                       from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n                                       left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n                                       on pa.products_attributes_id=pad.products_attributes_id\n                                       where pa.products_id = '" . $order->products[$i]['id'] . "'\n                                       and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n                                       and pa.options_id = popt.products_options_id\n                                       and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n                                       and pa.options_values_id = poval.products_options_values_id";
                         $attributes = $db->Execute($attributes_query);
                     } else {
                         $attributes = $db->Execute("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id");
                     }
                     $attributes_values = $attributes->fields;
                     $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']);
                     zen_db_perform(TABLE_GETFINANCING_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
                     if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
                         $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']);
                         zen_db_perform(TABLE_GETFINANCING_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
                     }
                 }
             }
         }
         // end - proceso estandar para generar el pedido
         $pagamastardeOrderGeneratedInConfirmation = $insert_id;
         $_SESSION['order_number_created'] = $insert_id;
         //$_SESSION['cart']->cartID = $_SESSION['cart']->generate_cart_id();
     }
     return false;
 }
开发者ID:GetFinancing,项目名称:getfinancing-zencart,代码行数:72,代码来源:getfinancing.php

示例13: calculate_deductions

 function calculate_deductions($order_total)
 {
     global $gBitDb, $gBitCustomer, $order;
     $tax_address = zen_get_tax_locations();
     $od_amount['total'] = 0;
     $od_amount['tax'] = 0;
     if ($_SESSION['cc_id']) {
         $coupon = new CommerceVoucher($_SESSION['cc_id']);
         if ($coupon->load() && $coupon->isRedeemable()) {
             if ($coupon->getField('coupon_minimum_order') <= $order_total) {
                 if ($coupon->getField('coupon_type') == 'S') {
                     if ($coupon->getField('restrict_to_shipping')) {
                         $shippingMethods = explode(',', $coupon->getField('restrict_to_shipping'));
                         if (in_array($order->info['shipping_method_code'], $shippingMethods)) {
                             $od_amount['total'] = $order->info['shipping_cost'];
                         }
                     } else {
                         $od_amount['total'] = $order->info['shipping_cost'];
                     }
                     $od_amount['type'] = 'S';
                 } else {
                     if ($coupon->getField('coupon_type') == 'P') {
                         // Max discount is a sum of percentages of valid products
                         $totalDiscount = 0;
                     } else {
                         $totalDiscount = $coupon->getField('coupon_amount') * ($order_total > 0);
                     }
                     $runningDiscount = 0;
                     $runningDiscountQuantity = 0;
                     foreach (array_keys($gBitCustomer->mCart->contents) as $productKey) {
                         $productHash = $gBitCustomer->mCart->getProductHash($productKey);
                         if ($coupon->getField('quantity_max')) {
                             if ($discountQuantity = $coupon->getField('quantity_max') - $runningDiscountQuantity) {
                                 if ($discountQuantity > $productHash['products_quantity']) {
                                     $discountQuantity = $productHash['products_quantity'];
                                 }
                             }
                         } else {
                             $discountQuantity = $productHash['products_quantity'];
                         }
                         if ($productHash && $discountQuantity && $this->is_product_valid($productHash, $_SESSION['cc_id'])) {
                             // _P_ercentage discount
                             if ($coupon->getField('coupon_type') == 'P') {
                                 $runningDiscountQuantity += $discountQuantity;
                                 $itemDiscount = round($productHash['final_price'] * $discountQuantity * ($coupon->getField('coupon_amount') / 100), 2);
                                 $totalDiscount += $itemDiscount;
                                 if ($runningDiscount < $totalDiscount) {
                                     $runningDiscount += $itemDiscount;
                                 }
                                 if ($runningDiscount > $totalDiscount) {
                                     $runningDiscount = $totalDiscount;
                                     $itemDiscount = 0;
                                 }
                                 switch ($this->calculate_tax) {
                                     case 'Credit Note':
                                         $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $od_amount[$tax_desc] = $runningDiscount / 100 * $tax_rate;
                                         $od_amount['tax'] += $od_amount[$tax_desc];
                                         break;
                                     case 'Standard':
                                         $ratio = $runningDiscount / $this->get_order_total();
                                         $tax_rate = zen_get_tax_rate($productHash['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($productHash['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                         if ($tax_rate > 0) {
                                             if (empty($od_amount[$tax_desc])) {
                                                 $od_amount[$tax_desc] = 0;
                                             }
                                             $od_amount[$tax_desc] += $productHash['final_price'] * $discountQuantity * $tax_rate / 100 * $ratio;
                                             $od_amount['tax'] += $od_amount[$tax_desc];
                                         }
                                         break;
                                 }
                                 // _F_ixed discount
                             } elseif ($coupon->getField('coupon_type') == 'F') {
                                 switch ($this->calculate_tax) {
                                     case 'Credit Note':
                                         $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $od_amount[$tax_desc] = $runningDiscount / 100 * $tax_rate;
                                         $od_amount['tax'] += $od_amount[$tax_desc];
                                         break;
                                     case 'Standard':
                                         $ratio = $runningDiscount / $this->get_order_total();
                                         $t_prid = zen_get_prid($productKey);
                                         $cc_result = $gBitDb->query("select `products_tax_class_id` from " . TABLE_PRODUCTS . " where `products_id` = ?", array($t_prid));
                                         if ($this->is_product_valid($productHash, $_SESSION['cc_id'])) {
                                             if ($runningDiscount < $totalDiscount) {
                                                 $runningDiscount += $productHash['final_price'] * $discountQuantity;
                                             }
                                             if ($runningDiscount > $totalDiscount) {
                                                 $runningDiscount = $totalDiscount;
                                             }
                                             $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                             $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                             if ($tax_rate > 0) {
                                                 if (empty($od_amount[$tax_desc])) {
                                                     $od_amount[$tax_desc] = 0;
                                                 }
                                                 $od_amount[$tax_desc] += $productHash['final_price'] * $discountQuantity * $tax_rate / 100 * $ratio;
//.........这里部分代码省略.........
开发者ID:bitweaver,项目名称:commerce,代码行数:101,代码来源:ot_coupon.php

示例14: updateNotifyOrderProcessingStockDecrementEnd

 function updateNotifyOrderProcessingStockDecrementEnd(&$callingClass, $notifier, $paramsArray)
 {
     //Need to modify the email that is going out regarding low-stock.
     //paramsArray is $i at time of development.
     if ($this->_orderIsSBA) {
         // Only take SBA action on SBA tracked product mc12345678 12-18-2015
         if ($callingClass->email_low_stock == '' && $callingClass->doStockDecrement && $this->_stock_values->RecordCount() > 0 && $this->_attribute_stock_left <= STOCK_REORDER_LEVEL) {
             // kuroi: trigger and details for attribute low stock email
             $callingClass->email_low_stock .= 'ID# ' . zen_get_prid($this->_productI['id']) . ', model# ' . $this->_productI['model'] . ', customid ' . $this->_productI['customid'] . ', name ' . $this->_productI['name'] . ', ';
             foreach ($this->_productI['attributes'] as $attributes) {
                 $callingClass->email_low_stock .= $attributes['option'] . ': ' . $attributes['value'] . ', ';
             }
             $callingClass->email_low_stock .= 'Stock: ' . $this->_attribute_stock_left . "\n\n";
             // kuroi: End Stock by Attribute additions
         }
     }
 }
开发者ID:badarac,项目名称:stock_by_attribute_1.5.4,代码行数:17,代码来源:class.products_with_attributes_stock.php

示例15: zen_get_customid

    function zen_get_customid($products_id, $attributes = null)
    {
        global $db;
        $customid_model_query = null;
        $customid_query = null;
        $products_id = zen_get_prid($products_id);
        // check if there are attributes for this product
        $stock_has_attributes_query = 'select products_attributes_id 
  											from ' . TABLE_PRODUCTS_ATTRIBUTES . ' 
  											where products_id = :products_id:';
        $stock_has_attributes_query = $db->bindVars($stock_has_attributes_query, ':products_id:', $products_id, 'integer');
        $stock_has_attributes = $db->Execute($stock_has_attributes_query);
        if ($stock_has_attributes->RecordCount() < 1) {
            //if no attributes return products_model
            $no_attribute_stock_query = 'select products_model 
  										from ' . TABLE_PRODUCTS . ' 
  										where products_id = :products_id:';
            $no_attribute_stock_query = $db->bindVars($no_attribute_stock_query, ':products_id:', $products_id, 'integer');
            $customid = $db->Execute($no_attribute_stock_query);
            return $customid->fields['products_model'];
        } else {
            if (is_array($attributes) and sizeof($attributes) > 0) {
                // check if attribute stock values have been set for the product
                // if there are will we continue, otherwise we'll use product level data
                $attribute_stock = $db->Execute("select stock_id \n\t\t\t\t\t\t\t  \t\t\t\t\tfrom " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " \n\t\t\t\t\t\t\t  \t\t\t\t\twhere products_id = " . (int) $products_id . ";");
                if ($attribute_stock->RecordCount() > 0) {
                    // search for details for the particular attributes combination
                    $first_search = 'where options_values_id in ("' . implode('","', $attributes) . '")';
                    // obtain the attribute ids
                    $query = 'select products_attributes_id 
  						from ' . TABLE_PRODUCTS_ATTRIBUTES . ' 
  								' . $first_search . ' 
  								and products_id=' . $products_id . ' 
  								order by products_attributes_id;';
                    $attributes_new = $db->Execute($query);
                    while (!$attributes_new->EOF) {
                        $stock_attributes[] = $attributes_new->fields['products_attributes_id'];
                        $attributes_new->MoveNext();
                    }
                    $stock_attributes_comb = implode(',', $stock_attributes);
                }
                //Get product model
                $customid_model_query = 'select products_model 
						  					from ' . TABLE_PRODUCTS . ' 
						  					where products_id = ' . (int) $products_id . ';';
                //Get custom id as products_model
                $customid_query = 'select customid as products_model
		  							from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' 
		  							where products_id = :products_id: 
		  							and stock_attributes in (:stock_attributes:);';
                $customid_query = $db->bindVars($customid_query, ':products_id:', $products_id, 'integer');
                $customid_query = $db->bindVars($customid_query, ':stock_attributes:', $stock_attributes_comb, 'string');
                $customid = $db->Execute($customid_query);
                //moved to inside this loop as for some reason it has made
                if (!$customid->RecordCount()) {
                    // if a customid does not exist for the combination of attributes then perhaps the attributes are individually listed.
                    $customid_query = 'select customid as products_model
		  							from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' 
		  							where products_id = :products_id: 
		  							and stock_attributes in (:stock_attributes:)';
                    $customid_query = $db->bindVars($customid_query, ':products_id:', $products_id, 'integer');
                    $customid_query = $db->bindVars($customid_query, ':stock_attributes:', $stock_attributes_comb, 'passthru');
                    $customid = $db->Execute($customid_query);
                    //moved to inside this loop as for some reason it has made
                }
            }
            //  		$customid = $db->Execute($customid_query);
            if ($customid->fields['products_model']) {
                //Test to see if a custom ID exists
                //if there are custom IDs with the attribute, then return them.
                $multiplecid = null;
                //mc12345678: Alternative to the below would be to build an array of "products_model" then implode
                //  the array on ', '... Both methods would require stepping through each of the
                //  returned values to build the desired structure.  The below does all of the
                //  implode in one swoop, though does not account for some of the individual items having
                //  a customid while others do not and thus could get x, y, , w, , z as an example.
                //  Either this is something identified up front, is prevented from happening at all, or
                //  is controllable through some form of "switch".  The maximum flexibility of this is
                //  covered by adding an if statement to the below, otherwise if going to build an array
                //  to then be imploded, separate action would need to take place to eliminate the "blanks".
                while (!$customid->EOF) {
                    $multiplecid .= $customid->fields['products_model'] . ', ';
                    $customid->MoveNext();
                }
                $multiplecid = rtrim($multiplecid, ', ');
                //return result for display
                return $multiplecid;
            } else {
                $customid = null;
                //This is used as a fall-back when custom ID is set to be displayed but no attribute is available.
                //Get product model
                $customid_model_query = 'select products_model
						  					from ' . TABLE_PRODUCTS . '
						  					where products_id = :products_id:';
                $customid_model_query = $db->bindVars($customid_model_query, ':products_id:', $products_id, 'integer');
                $customid = $db->Execute($customid_model_query);
                //return result for display
                return $customid->fields['products_model'];
            }
            return;
//.........这里部分代码省略.........
开发者ID:badarac,项目名称:stock_by_attribute_1.5.4,代码行数:101,代码来源:products_with_attributes_stock.php


注:本文中的zen_get_prid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。