From 5110146c1cfdba0d9395bd44c35dc3a7198f1aa9 Mon Sep 17 00:00:00 2001 From: spiderr Date: Thu, 14 Jun 2018 15:44:12 -0400 Subject: [PATCH 01/11] fix rounding for adjusted order total; remove zen_round calls --- includes/classes/currencies.php | 12 ++++++++---- includes/modules/order_total/ot_total.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/classes/currencies.php b/includes/classes/currencies.php index 34461baf..b7fcac7b 100644 --- a/includes/classes/currencies.php +++ b/includes/classes/currencies.php @@ -82,6 +82,10 @@ public function expungeCurrency( $pCurrency ) { // class methods + function roundValue( $pValue, $pCurrency=DEFAULT_CURRENCY ) { + return round( $pValue, $this->currencies[$pCurrency]['decimal_places']); + } + function convert( $pValue, $pToCurrency=NULL, $pFromCurrency=DEFAULT_CURRENCY ) { $convertValue = $pValue; if( empty( $pToCurrency ) ) { @@ -95,7 +99,7 @@ function convert( $pValue, $pToCurrency=NULL, $pFromCurrency=DEFAULT_CURRENCY ) $convertValue = $convertValue * $this->currencies[$pToCurrency]['currency_value']; } } - return zen_round( $convertValue, $this->currencies[$pToCurrency]['decimal_places']); + return round( $convertValue, $this->currencies[$pToCurrency]['decimal_places']); } function displayConversion( $pValue, $pToCurrency, $pFromCurrency=DEFAULT_CURRENCY ) { @@ -112,7 +116,7 @@ function format($number, $calculate_currency_value = true, $currency_type = '', $rate = 1; } - $format_string .= number_format(zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']); + $format_string .= number_format(round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']); if( $this->currencies[$currency_type]['decimal_places'] ) { $format_string = str_replace( $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['decimal_point'].'', $format_string).''; @@ -138,9 +142,9 @@ function value($number, $calculate_currency_value = true, $currency_type = '', $ } else { $rate = (zen_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['currency_value']; } - $currency_value = zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']); + $currency_value = round($number * $rate, $this->currencies[$currency_type]['decimal_places']); } else { - $currency_value = zen_round($number, $this->currencies[$currency_type]['decimal_places']); + $currency_value = round($number, $this->currencies[$currency_type]['decimal_places']); } return $currency_value; diff --git a/includes/modules/order_total/ot_total.php b/includes/modules/order_total/ot_total.php index 7b72c970..741f7a8c 100644 --- a/includes/modules/order_total/ot_total.php +++ b/includes/modules/order_total/ot_total.php @@ -29,7 +29,7 @@ protected function getStatusKey() { function process() { parent::process(); global $currencies; - $total = $this->mOrder->info['total'] - $this->mOrder->getDeductionTotal(); + $total = $currencies->roundValue( $this->mOrder->info['total'] - $this->mOrder->getDeductionTotal() ); $this->mProcessingOutput = array( 'code' => $this->code, 'sort_order' => $this->getSortOrder(), 'title' => $this->title . ':', From e5300b61186b4437f4d024c0248b07c759c76581 Mon Sep 17 00:00:00 2001 From: spiderr Date: Thu, 14 Jun 2018 16:40:59 -0400 Subject: [PATCH 02/11] clean up default product --- templates/page_product_info.tpl | 61 +++++++++++++-------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/templates/page_product_info.tpl b/templates/page_product_info.tpl index dde1aef0..43fa9048 100644 --- a/templates/page_product_info.tpl +++ b/templates/page_product_info.tpl @@ -11,9 +11,9 @@ {/if} - +
{assign var=thumbUrl value=$gBitProduct->getImageUrl('large')} @@ -23,7 +23,7 @@
{/if} -
+
{form name='cart_quantity' action="`$smarty.const.BITCOMMERCE_PKG_URL`index.php?products_id=`$smarty.get.products_id`&action=add_product" method='post' enctype='multipart/form-data'}
@@ -81,10 +81,10 @@ {/if} {if $gBitProduct->getField('products_discount_type')} -
- {assign var="modDir" value=$smarty.const.FILENAME_PRODUCTS_DISCOUNT_PRICES|zen_get_module_directory} - {include_php file="`$smarty.const.DIR_FS_MODULES``$modDir`"} -
+
+ {assign var="modDir" value=$smarty.const.FILENAME_PRODUCTS_DISCOUNT_PRICES|zen_get_module_directory} + {include_php file="`$smarty.const.DIR_FS_MODULES``$modDir`"} +
{/if} {if $smarty.const.CUSTOMERS_APPROVAL == '3' and $smarty.const.TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == ''} @@ -109,44 +109,31 @@
{/if} -
-
- - - {if $smarty.const.PRODUCT_INFO_PREVIOUS_NEXT == '2' || $smarty.const.PRODUCT_INFO_PREVIOUS_NEXT == '3'} -
- {include_php file="`$smarty.const.BITCOMMERCE_PKG_PATH`includes/templates/template_default/common/tpl_products_next_previous.php"} -
- {/if} + + {if $smarty.const.PRODUCT_INFO_PREVIOUS_NEXT == '2' || $smarty.const.PRODUCT_INFO_PREVIOUS_NEXT == '3'} +
+ {include_php file="`$smarty.const.BITCOMMERCE_PKG_PATH`includes/templates/template_default/common/tpl_products_next_previous.php"} +
+ {/if} - {if $smarty.const.SHOW_PRODUCT_INFO_DATE_AVAILABLE == '1' && $gBitProduct->getField('products_date_available') > date('Y-m-d H:i:s')} -
- {tr}This product will be in stock on{/tr} {$gBitProduct->getField('products_date_available')|zen_date_long} -
- {elseif $smarty.const.SHOW_PRODUCT_INFO_DATE_ADDED == '1'} -
- {tr}This product was added to our catalog on{/tr} {$gBitProduct->getField('products_date_added')|zen_date_long} -
- {/if} + {if $smarty.const.SHOW_PRODUCT_INFO_DATE_AVAILABLE == '1' && $gBitProduct->getField('products_date_available') > date('Y-m-d H:i:s')} +
+ {tr}This product will be in stock on{/tr} {$gBitProduct->getField('products_date_available')|zen_date_long} +
+ {elseif $smarty.const.SHOW_PRODUCT_INFO_DATE_ADDED == '1'} +
+ {tr}This product was added to our catalog on{/tr} {$gBitProduct->getField('products_date_added')|zen_date_long} +
+ {/if} - {if $gBitProduct->getField('products_url') && $smarty.const.SHOW_PRODUCT_INFO_URL == '1'} -
- {* *} +
- {/if} - {/form} -
{if $smarty.const.SHOW_PRODUCT_INFO_REVIEWS == '1' AND $gBitSystem->isFeatureActive( 'wiki_comments' )} -
-
{include file="bitpackage:liberty/comments.tpl"} -
-
{/if} -
From cc6715ac9e1fff35b97ffd269f72ef08eb993479 Mon Sep 17 00:00:00 2001 From: spiderr Date: Fri, 15 Jun 2018 14:42:15 -0400 Subject: [PATCH 03/11] large purge of antiquated zen_get_products_quantity_* functions and replace with CommerceProduct:: equivalent, remove functions_prices.php as all functionality pushed out to CommerceProduct --- admin/includes/application_top.php | 1 - admin/includes/functions/functions_prices.php | 143 ------------ classes/CommerceProduct.php | 122 +++++----- classes/CommerceShoppingCart.php | 49 ++-- includes/application_top.php | 6 +- .../blocks/blk_advanced_search_result.php | 2 +- includes/common_inc.php | 123 ++++++---- includes/functions/functions_general.php | 2 - includes/functions/functions_prices.php | 211 ------------------ .../modules/featured_products_listing.php | 4 +- includes/modules/product_listing.php | 2 +- includes/modules/products_all_listing.php | 4 +- includes/modules/products_new_listing.php | 4 +- .../document_product_info_display.php | 2 +- .../product_free_shipping_info_display.php | 2 +- .../product_music_info_display.php | 2 +- pages/product_reviews/product_reviews.php | 2 +- .../product_reviews_info.php | 2 +- templates/list_products_inc.tpl | 2 +- templates/page_product_info.tpl | 2 +- 20 files changed, 173 insertions(+), 514 deletions(-) delete mode 100644 admin/includes/functions/functions_prices.php delete mode 100644 includes/functions/functions_prices.php diff --git a/admin/includes/application_top.php b/admin/includes/application_top.php index cf6cad49..089b3bcd 100644 --- a/admin/includes/application_top.php +++ b/admin/includes/application_top.php @@ -147,7 +147,6 @@ // define our general functions used application-wide require_once(DIR_WS_FUNCTIONS . 'general.php'); require_once( BITCOMMERCE_PKG_PATH.'classes/CommerceVoucher.php' ); -require_once(DIR_WS_FUNCTIONS . 'functions_prices.php'); require_once(DIR_WS_FUNCTIONS . 'html_output.php'); require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'functions_email.php'); diff --git a/admin/includes/functions/functions_prices.php b/admin/includes/functions/functions_prices.php deleted file mode 100644 index 81c959b9..00000000 --- a/admin/includes/functions/functions_prices.php +++ /dev/null @@ -1,143 +0,0 @@ - 1 or $check_units > 1) { - if ($check_min > 1) { - $the_min_units .= PRODUCTS_QUANTITY_MIN_TEXT_LISTING . ' ' . $check_min; - } - if ($check_units > 1) { - $the_min_units .= ($the_min_units ? ' ' : '' ) . PRODUCTS_QUANTITY_UNIT_TEXT_LISTING . ' ' . $check_units; - } - - if (($check_min > 0 or $check_units > 0) and !zen_get_products_quantity_mixed($product_id)) { - if ($include_break == true) { - $the_min_units .= '
' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART); - } else { - $the_min_units .= '  ' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART); - } - } else { - if ($include_break == true) { - $the_min_units .= '
' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART); - } else { - $the_min_units .= '  ' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART); - } - } - } - - // quantity max - $check_max = zen_get_products_quantity_order_max($product_id); - - if ($check_max != 0) { - if ($include_break == true) { - $the_min_units .= ($the_min_units != '' ? '
' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max; - } else { - $the_min_units .= ($the_min_units != '' ? '  ' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max; - } - } - - return $the_min_units; - } - - -//// -// look up discount in sale makers - attributes only can have discounts if set as percentages -// this gets the discount amount this does not determin when to apply the discount - function zen_get_products_sale_discount($product_id = false, $categories_id = false, $display_type = false) { - global $currencies; - global $gBitDb; - -// get products category - if ($categories_id == true) { - $check_category = $categories_id; - } else { - $check_category = zen_get_products_category_id($product_id); - } - - $deduction_type_array = array(array('id' => '0', 'text' => DEDUCTION_TYPE_DROPDOWN_0), - array('id' => '1', 'text' => DEDUCTION_TYPE_DROPDOWN_1), - array('id' => '2', 'text' => DEDUCTION_TYPE_DROPDOWN_2)); - - $sale_maker_discount = 0; - $sale_maker_discount_type = FALSE; - $salemaker_sales = $gBitDb->Execute("select `sale_id`, `sale_status`, `sale_name`, `sale_categories_all`, `sale_deduction_value`, `sale_deduction_type`, `sale_pricerange_from`, `sale_pricerange_to`, `sale_specials_condition`, `sale_categories_selected`, `sale_date_start`, `sale_date_end`, `sale_date_added`, `sale_date_last_modified`, `sale_date_status_change` from " . TABLE_SALEMAKER_SALES . " where `sale_status`='1'"); - while (!$salemaker_sales->EOF) { - $categories = explode(',', $salemaker_sales->fields['sale_categories_all']); - while (list($key,$value) = each($categories)) { - if ($value == $check_category) { - $sale_maker_discount = $salemaker_sales->fields['sale_deduction_value']; - $sale_maker_discount_type = $salemaker_sales->fields['sale_deduction_type']; - break; - } - } - $salemaker_sales->MoveNext(); - } - - switch(true) { - // percentage discount only - case ($sale_maker_discount_type == 1): - $sale_maker_discount = (1 - ($sale_maker_discount / 100)); - break; - case ($sale_maker_discount_type == 0 and $display_type == true): - $sale_maker_discount = $sale_maker_discount; - break; - case ($sale_maker_discount_type == 0 and $display_type == false): - $sale_maker_discount = $sale_maker_discount; - break; - case ($sale_maker_discount_type == 2 and $display_type == true): - $sale_maker_discount = $sale_maker_discount; - break; - default: - $sale_maker_discount = 1; - break; - } - - if ($display_type == true) { - if ($sale_maker_discount != 1 and $sale_maker_discount !=0) { - switch(true) { - case ($sale_maker_discount_type == 0): - $sale_maker_discount = $currencies->format($sale_maker_discount) . ' ' . $deduction_type_array[$sale_maker_discount_type]['text']; - break; - case ($sale_maker_discount_type == 2): - $sale_maker_discount = $currencies->format($sale_maker_discount) . ' ' . $deduction_type_array[$sale_maker_discount_type]['text']; - break; - case ($sale_maker_discount_type == 1): - $sale_maker_discount = number_format( (1.00 - $sale_maker_discount),2,".","") . ' ' . $deduction_type_array[$sale_maker_discount_type]['text']; - break; - } - } else { - $sale_maker_discount = ''; - } - } - return $sale_maker_discount; - } - -?> diff --git a/classes/CommerceProduct.php b/classes/CommerceProduct.php index 92e1a606..73615565 100644 --- a/classes/CommerceProduct.php +++ b/classes/CommerceProduct.php @@ -1885,6 +1885,7 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $products_options_display_weight=''; } + // =-=-=-=-=-=-=-=-=-=-= FILE, TEXT, READONLY if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or count( $this->mOptions[$optionsId] ) == 1 or $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) { $products_options_value_id = $vals['products_options_values_id']; @@ -1895,13 +1896,15 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $products_options_details = ''; } if ($this->mOptions[$optionsId]['products_options_images_style'] >= 3) { - $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight : ''); - $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight : ''); + $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight . '
' : ''); + $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight . '
' : ''); } else { $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? ' ' . $products_options_display_weight : ''); $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? ' ' . $products_options_display_weight : ''); } } + + // =-=-=-=-=-=-=-=-=-=-= radio buttons if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO) { if( is_object( $pCart ) && $pCart->in_cart($this->mProductsId) && ($pCart->contents[$this->mProductsId]['attributes'][$this->mOptions[$optionsId]['products_options_id']] == $vals['products_options_values_id']) ) { @@ -1928,10 +1931,7 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting } - - // =-=-=-=-=-=-=-=-=-=-= checkboxes - if ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX) { $string = $this->mOptions[$optionsId]['products_options_id'].'_chk'.$vals['products_options_values_id']; if( is_object( $pCart ) && $pCart->in_cart($this->mProductsId)) { @@ -2415,93 +2415,77 @@ function quantityInCart( $pProductsId = NULL ) { //// // Return quantity buy now - function getBuyNowQuantity( $pProductsId = NULL) { + // The function formerly known as zen_get_buy_now_qty + function getBuyNowQuantity() { global $gBitCustomer; - if( empty( $pProductsId ) && !empty( $this->mProductsId ) ) { - $pProductsId = $this->mProductsId; - } + $ret = 1; + + $check_min = $this->getField( 'products_quantity_order_min' ); + $check_units = $this->getField( 'products_quantity_order_units' ); + $inCartMixed = $gBitCustomer->mCart->in_cart_mixed( $this->mProductsId ); - $check_min = zen_get_products_quantity_order_min( $pProductsId ); - $check_units = zen_get_products_quantity_order_units( $pProductsId ); - $buy_now_qty=1; // works on Mixed ON - switch (true) { - case ($gBitCustomer->mCart->in_cart_mixed($pProductsId) == 0 ): - if ($check_min >= $check_units) { - $buy_now_qty = $check_min; - } else { - $buy_now_qty = $check_units; - } - break; - case ($gBitCustomer->mCart->in_cart_mixed($pProductsId) < $check_min): - $buy_now_qty = $check_min - $gBitCustomer->mCart->in_cart_mixed($pProductsId); - break; - case ($gBitCustomer->mCart->in_cart_mixed($pProductsId) > $check_min): - // set to units or difference in units to balance cart - $new_units = $check_units - fmod($gBitCustomer->mCart->in_cart_mixed($pProductsId), $check_units); - //echo 'Cart: ' . $gBitCustomer->mCart->in_cart_mixed($pProductsId) . ' Min: ' . $check_min . ' Units: ' . $check_units . ' fmod: ' . fmod($gBitCustomer->mCart->in_cart_mixed($pProductsId), $check_units) . '
'; - $buy_now_qty = ($new_units > 0 ? $new_units : $check_units); - break; - default: - $buy_now_qty = $check_units; - break; + if( $gBitCustomer->mCart->in_cart_mixed($pProductsId) == 0 ) { + if ($check_min >= $check_units) { + $ret = $check_min; + } else { + $ret = $check_units; + } + } elseif( $inCartMixed < $check_min ) { + $ret = $check_min - $gBitCustomer->mCart->in_cart_mixed($pProductsId); + } elseif( $inCartMixed > $check_min ) { + // set to units or difference in units to balance cart + $new_units = $check_units - fmod($gBitCustomer->mCart->in_cart_mixed($pProductsId), $check_units); + $ret = ($new_units > 0 ? $new_units : $check_units); + } else { + $ret = $check_units; } - if ($buy_now_qty <= 0) { - $buy_now_qty = 1; + + if ($ret <= 0) { + $ret = 1; } - return $buy_now_qty; + return $ret; } //// // Return a products quantity minimum and units display - function getQuantityMinUnitsDisplay($pProductsId = NULL, $include_break = true, $shopping_cart_msg = false) { - if( empty( $pProductsId ) && !empty( $this->mProductsId ) ) { - $pProductsId = $this->mProductsId; - } - $check_min = zen_get_products_quantity_order_min($pProductsId); - $check_units = zen_get_products_quantity_order_units($pProductsId); + // The function formerly known as zen_get_products_quantity_min_units_display + function getQuantityMinUnitsDisplay() { - $the_min_units=''; + $ret='
'; - if ($check_min != 1 or $check_units != 1) { - if ($check_min != 1) { - $the_min_units .= PRODUCTS_QUANTITY_MIN_TEXT_LISTING . ' ' . $check_min; - } - if ($check_units != 1) { - $the_min_units .= ($the_min_units ? ' ' : '' ) . PRODUCTS_QUANTITY_UNIT_TEXT_LISTING . ' ' . $check_units; - } + if( $this->isValid() ) { + $check_min = $this->getField( 'products_quantity_order_min' ); + $check_units = $this->getField( 'products_quantity_order_units' ); - if (($check_min > 0 or $check_units > 0) and !zen_get_products_quantity_mixed($pProductsId)) { - if ($include_break == true) { - $the_min_units .= '
' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART); - } else { - $the_min_units .= '  ' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART); + // quantity min + if ($check_min != 1 or $check_units != 1) { + if ($check_min != 1) { + $ret .= PRODUCTS_QUANTITY_MIN_TEXT_LISTING . ' ' . $check_min; } - } else { - if ($include_break == true) { - $the_min_units .= '
' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART); - } else { - $the_min_units .= '  ' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART); + if ($check_units != 1) { + $ret .= ($ret ? ' ' : '' ) . PRODUCTS_QUANTITY_UNIT_TEXT_LISTING . ' ' . $check_units; } - } - } - // quantity max - $check_max = zen_get_products_quantity_order_max($pProductsId); + if( ($check_min > 0 or $check_units > 0) && $this->getField('products_quantity_mixed') != 1 ) { + $ret .= ', ' . tra( 'must have the same options' ); + } + } - if ($check_max != 0) { - if ($include_break == true) { - $the_min_units .= ($the_min_units != '' ? '
' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max; - } else { - $the_min_units .= ($the_min_units != '' ? '  ' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max; + // quantity max + $check_max = $this->getField( 'products_quantity_order_max' ); + if ($check_max != 0) { + $ret .= '' . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max . ''; } } + $ret .= '
'; - return $the_min_units; + return $ret; } + function expungeNotification( $pCustomersId, $pProductsId=NULL ) { if( empty( $pProductsId ) ) { $pProductsId = $this->mProductsId; diff --git a/classes/CommerceShoppingCart.php b/classes/CommerceShoppingCart.php index bec5486d..1411c01e 100644 --- a/classes/CommerceShoppingCart.php +++ b/classes/CommerceShoppingCart.php @@ -162,24 +162,24 @@ function verifyQuantity( $pProductsKey, $pQty ) { $pQty = (int)$pQty; - // verify qty to add - $add_max = zen_get_products_quantity_order_max($_REQUEST['products_id']); - $cart_qty = $gBitCustomer->mCart->in_cart_mixed($_REQUEST['products_id']); - $new_qty = zen_get_buy_now_qty($_REQUEST['products_id']); - if (($add_max == 1 and $cart_qty == 1)) { - // do not add - $new_qty = 0; - } else { - // adjust quantity if needed - if (($new_qty + $cart_qty > $add_max) and $add_max != 0) { - $new_qty = $add_max - $cart_qty; + if( $product = $this->getProductObject( $pProductsKey ) ) { + // verify qty to add + $add_max = $product->getField( 'products_quantity_order_max' ); + $cart_qty = $gBitCustomer->mCart->in_cart_mixed($_REQUEST['products_id']); + $new_qty = zen_get_buy_now_qty($_REQUEST['products_id']); + if (($add_max == 1 and $cart_qty == 1)) { + // do not add + $new_qty = 0; + } else { + // adjust quantity if needed + if (($new_qty + $cart_qty > $add_max) and $add_max != 0) { + $new_qty = $add_max - $cart_qty; + } + } + if( !empty( $adjust_max ) && $adjust_max == 'true' ) { + $messageStack->add_session('header', ERROR_MAXIMUM_QTY . ' - ' . zen_get_products_name($prodId), 'caution'); } - } - if( !empty( $adjust_max ) && $adjust_max == 'true' ) { - $messageStack->add_session('header', ERROR_MAXIMUM_QTY . ' - ' . zen_get_products_name($prodId), 'caution'); - } - if( $product = $this->getProductObject( $pProductsKey ) ) { if( is_object( $product ) && $pQty > $product->getField( 'products_quantity_order_max' ) ) { // we are trying to add quantity greater than max purchable quantity $pQty = $product->getField( 'products_quantity_order_max' ); @@ -206,27 +206,24 @@ function verifyCheckout() { $fix_once = 0; if ($check_quantity < $check_quantity_min) { $fix_once ++; - $this->mErrors['checkout'][$productsKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . zen_get_products_quantity_min_units_display(zen_get_prid( $productsKey ), false, true) . ' '; + $this->mErrors['checkout'][$productsKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . $product->getQuantityMinUnitsDisplay() . ' '; } // Check Quantity Units if not already an error on Quantity Minimum if ($fix_once == 0) { $check_units = $product->getField( 'products_quantity_order_units' ); if ( fmod($check_quantity,$check_units) != 0 ) { - $this->mErrors['checkout'][$productsKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . zen_get_products_quantity_min_units_display(zen_get_prid( $productsKey ), false, true) . ' '; + $this->mErrors['checkout'][$productsKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . $product->getQuantityMinUnitsDisplay() . ' '; } } // Check if the required stock is available. If insufficent stock is available return an out of stock message if ( $gCommerceSystem->getConfig( 'STOCK_CHECK' ) && !$gCommerceSystem->getConfig( 'STOCK_ALLOW_CHECKOUT' ) ) { - foreach( $this->contents AS $productsKey => $productsHash ) { - $product = $this->getProductObject( $productsKey ); - if( !$product->getField( 'products_quantity' ) && !$product->getField( 'products_virtual' ) ) { - if( $gCommerceSystem->getConfig( 'STOCK_ALLOW_CHECKOUT' ) ) { - $this->mErrors['checkout'][$productsKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock.
Items not in stock will be placed on backorder.' ); - } else { - $this->mErrors['checkout'][$productsKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock or there are not enough in stock to fill your order.
Please change the quantity of products marked with (' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '). Thank you' ); - } + if( !$product->getField( 'products_quantity' ) && !$product->getField( 'products_virtual' ) ) { + if( $gCommerceSystem->getConfig( 'STOCK_ALLOW_CHECKOUT' ) ) { + $this->mErrors['checkout'][$productsKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock.
Items not in stock will be placed on backorder.' ); + } else { + $this->mErrors['checkout'][$productsKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock or there are not enough in stock to fill your order.
Please change the quantity of products marked with (' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '). Thank you' ); } } } diff --git a/includes/application_top.php b/includes/application_top.php index 7031f0a6..b39c7f86 100644 --- a/includes/application_top.php +++ b/includes/application_top.php @@ -265,11 +265,11 @@ function clean_input( &$pArray ) { break; // performed by the 'buy now' button in product listings and review page case 'buy_now' : - if (isset($_REQUEST['products_id'])) { + if (isset($_REQUEST['products_id']) && $gBitProduct->isValid() ) { if (zen_has_product_attributes($_REQUEST['products_id'])) { - zen_redirect( CommerceProduct::getDisplayUrlFromId( $_REQUEST['products_id']) ); + zen_redirect( $gBitProduct->getDisplayUrl() ); } else { - $gBitCustomer->mCart->addToCart($_REQUEST['products_id'], ($gBitCustomer->mCart->get_quantity( $_REQUEST['products_id'] ) + zen_get_buy_now_qty( $_REQUEST['products_id'] )) ); + $gBitCustomer->mCart->addToCart($_REQUEST['products_id'], ($gBitCustomer->mCart->get_quantity( $_REQUEST['products_id'] ) + $gBitProduct->getBuyNowQuantity() ) ); } } zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters))); diff --git a/includes/blocks/blk_advanced_search_result.php b/includes/blocks/blk_advanced_search_result.php index bb35bf83..14a00db5 100644 --- a/includes/blocks/blk_advanced_search_result.php +++ b/includes/blocks/blk_advanced_search_result.php @@ -336,7 +336,7 @@ } $the_button = $lc_button; $products_link = '' . MORE_INFO_TEXT . ''; - $lc_text .= '
' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($listing->fields['products_id']); + $lc_text .= '
' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link); break; case 'PRODUCT_LIST_QUANTITY': diff --git a/includes/common_inc.php b/includes/common_inc.php index c265844d..3c06afa0 100644 --- a/includes/common_inc.php +++ b/includes/common_inc.php @@ -560,7 +560,7 @@ function zen_get_products_price_is_priced_by_attributes($products_id) { " where `products_id` = ?", array( zen_get_prid( $products_id ) ) ); return( $product_check == '1' ); } - + /* MOVED TO CommerceProduct:: //// // Return a product's minimum quantity // TABLES: products @@ -592,49 +592,6 @@ function zen_get_products_quantity_order_max($product_id) { return $the_products_quantity_order_max->fields['products_quantity_order_max']; } -//// -// Find quantity discount quantity mixed and not mixed - function zen_get_products_quantity_discount_mixed($product_id, $qty) { - global $gBitDb; - global $gBitCustomer; - - $product_discounts = $gBitDb->query("select `products_price`, `products_quantity_mixed`, `product_is_free` from " . TABLE_PRODUCTS . " where `products_id` = '" . $product_id . "'"); - - if ($product_discounts->fields['products_quantity_mixed']) { - if ($new_qty = $gBitCustomer->mCart->count_contents_qty($product_id)) { - $qty = $new_qty; - } - } - return $qty; - } - - -//// -// Return a product's quantity box status -// TABLES: products - function zen_get_products_qty_box_status($product_id) { - global $gBitDb; - - $the_products_qty_box_status = $gBitDb->query("select `products_id`, `products_qty_box_status` from " . TABLE_PRODUCTS . " where `products_id` = '" . (int)$product_id . "'"); - return $the_products_qty_box_status->fields['products_qty_box_status']; - } - -//// -// Return a product mixed setting -// TABLES: products - function zen_get_products_quantity_mixed($product_id) { - global $gBitDb; - - $the_products_quantity_mixed = $gBitDb->query("select `products_id`, `products_quantity_mixed` from " . TABLE_PRODUCTS . " where `products_id` = '" . $product_id . "'"); - if ($the_products_quantity_mixed->fields['products_quantity_mixed'] == '1') { - $look_up = true; - } else { - $look_up = false; - } - return $look_up; - } - - //// // Return quantity buy now function zen_get_buy_now_qty($product_id) { @@ -671,6 +628,52 @@ function zen_get_buy_now_qty($product_id) { } +//// +// Find quantity discount quantity mixed and not mixed + function zen_get_products_quantity_discount_mixed($product_id, $qty) { + global $gBitDb; + global $gBitCustomer; + + $product_discounts = $gBitDb->query("select `products_price`, `products_quantity_mixed`, `product_is_free` from " . TABLE_PRODUCTS . " where `products_id` = '" . $product_id . "'"); + + if ($product_discounts->fields['products_quantity_mixed']) { + if ($new_qty = $gBitCustomer->mCart->count_contents_qty($product_id)) { + $qty = $new_qty; + } + } + return $qty; + } + +//// +// Return a product mixed setting +// TABLES: products + function zen_get_products_quantity_mixed($product_id) { + global $gBitDb; + + $the_products_quantity_mixed = $gBitDb->query("select `products_id`, `products_quantity_mixed` from " . TABLE_PRODUCTS . " where `products_id` = '" . $product_id . "'"); + if ($the_products_quantity_mixed->fields['products_quantity_mixed'] == '1') { + $look_up = true; + } else { + $look_up = false; + } + return $look_up; + } + +//// +// Return a product's quantity box status +// TABLES: products + function zen_get_products_qty_box_status($product_id) { + global $gBitDb; + + $the_products_qty_box_status = $gBitDb->query("select `products_id`, `products_qty_box_status` from " . TABLE_PRODUCTS . " where `products_id` = '" . (int)$product_id . "'"); + return $the_products_qty_box_status->fields['products_qty_box_status']; + } + + +*/ + + + //// // are there discount quanties function zen_get_discount_qty($product_id, $check_qty) { @@ -687,6 +690,38 @@ function zen_get_discount_qty($product_id, $check_qty) { } } +//// +// salemaker categories array + function zen_parse_salemaker_categories($clist) { + $clist_array = explode(',', $clist); + +// make sure no duplicate category IDs exist which could lock the server in a loop + $tmp_array = array(); + $n = sizeof($clist_array); + for ($i=0; $i<$n; $i++) { + if (!in_array($clist_array[$i], $tmp_array)) { + $tmp_array[] = $clist_array[$i]; + } + } + return $tmp_array; + } + +//// +// update salemaker product prices per category per product + function zen_update_salemaker_product_prices($salemaker_id) { + global $gBitDb; + $zv_categories = $gBitDb->Execute("select `sale_categories_selected` from " . TABLE_SALEMAKER_SALES . " where `sale_id` = '" . $salemaker_id . "'"); + + $za_salemaker_categories = zen_parse_salemaker_categories($zv_categories->fields['sale_categories_selected']); + $n = sizeof($za_salemaker_categories); + for ($i=0; $i<$n; $i++) { + $update_products_price = $gBitDb->Execute("select `products_id` from " . TABLE_PRODUCTS_TO_CATEGORIES . " where `categories_id`='" . $za_salemaker_categories[$i] . "'"); + while (!$update_products_price->EOF) { + zen_update_lowest_purchase_price($update_products_price->fields['products_id']); + $update_products_price->MoveNext(); + } + } + } //// // Return a product ID from a product ID with attributes diff --git a/includes/functions/functions_general.php b/includes/functions/functions_general.php index 139c4e61..7c57075b 100644 --- a/includes/functions/functions_general.php +++ b/includes/functions/functions_general.php @@ -959,8 +959,6 @@ function zen_check_url_get_terms() { ///////////////////////////////////////////// //// // call additional function files -// prices and quantities - require_once(BITCOMMERCE_PKG_PATH.'includes/functions/functions_prices.php'); // gv and coupons require_once(BITCOMMERCE_PKG_PATH.'classes/CommerceVoucher.php'); // categories, paths, pulldowns diff --git a/includes/functions/functions_prices.php b/includes/functions/functions_prices.php deleted file mode 100644 index e09a0b81..00000000 --- a/includes/functions/functions_prices.php +++ /dev/null @@ -1,211 +0,0 @@ - 0 or $check_units > 0) and !zen_get_products_quantity_mixed($product_id)) { - if ($include_break == true) { - $the_min_units .= '
' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART); - } else { - $the_min_units .= '  ' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_OFF : TEXT_PRODUCTS_MIX_OFF_SHOPPING_CART); - } - } else { - if ($include_break == true) { - $the_min_units .= '
' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART); - } else { - $the_min_units .= '  ' . ($shopping_cart_msg == false ? TEXT_PRODUCTS_MIX_ON : TEXT_PRODUCTS_MIX_ON_SHOPPING_CART); - } - } - } - - // quantity max - $check_max = zen_get_products_quantity_order_max($product_id); - - if ($check_max != 0) { - if ($include_break == true) { - $the_min_units .= ($the_min_units != '' ? '
' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max; - } else { - $the_min_units .= ($the_min_units != '' ? '  ' : '') . PRODUCTS_QUANTITY_MAX_TEXT_LISTING . ' ' . $check_max; - } - } - - return $the_min_units; - } - - -//// -// look up discount in sale makers - attributes only can have discounts if set as percentages -// this gets the discount amount this does not determin when to apply the discount - function zen_get_products_sale_discount($product_id = false, $categories_id = false, $display_type = false) { - global $currencies; - global $gBitDb; - -// NOT USED -echo '
' . 'I SHOULD use zen_get_discount_calc' . '
'; - -/* - -0 = flat amount off base price with a special -1 = Percentage off base price with a special -2 = New Price with a special - -5 = No Sale or Skip Products with Special - -special options + option * 10 -0 = Ignore special and apply to Price -1 = Skip Products with Specials switch to 5 -2 = Apply to Special Price - -If a special exist * 10 - -0+7 + 0+10 = flat apply to price = 17 or 170 -0+7 + 1+10 = flat skip Specials = 5 or 50 -0+7 + 2+10 = flat apply to special = 27 or 270 - -1+7 + 0+10 = Percentage apply to price = 18 or 180 -1+7 + 1+10 = Percentage skip Specials = 5 or 50 -1+7 + 2+10 = Percentage apply to special = 20 or 200 - -2+7 + 0+10 = New Price apply to price = 19 or 190 -2+7 + 1+10 = New Price skip Specials = 5 or 50 -2+7 + 2+10 = New Price apply to Special = 21 or 210 - -*/ - -/* -// get products category - if ($categories_id == true) { - $check_category = $categories_id; - } else { - $check_category = zen_get_products_category_id($product_id); - } - - $deduction_type_array = array(array('id' => '0', 'text' => DEDUCTION_TYPE_DROPDOWN_0), - array('id' => '1', 'text' => DEDUCTION_TYPE_DROPDOWN_1), - array('id' => '2', 'text' => DEDUCTION_TYPE_DROPDOWN_2)); - - $sale_maker_discount = 0; - $salemaker_sales = $gBitDb->Execute("select `sale_id`, `sale_status`, `sale_name`, `sale_categories_all`, `sale_deduction_value`, `sale_deduction_type`, `sale_pricerange_from`, `sale_pricerange_to`, `sale_specials_condition`, `sale_categories_selected`, `sale_date_start`, `sale_date_end`, `sale_date_added`, `sale_date_last_modified`, `sale_date_status_change` from " . TABLE_SALEMAKER_SALES . " where `sale_status`='1'"); - while (!$salemaker_sales->EOF) { - $categories = explode(',', $salemaker_sales->fields['sale_categories_all']); - while (list($key,$value) = each($categories)) { - if ($value == $check_category) { - $sale_maker_discount = $salemaker_sales->fields['sale_deduction_value']; - $sale_maker_discount_type = $salemaker_sales->fields['sale_deduction_type']; - break; - } - } - $salemaker_sales->MoveNext(); - } - - switch(true) { - // percentage discount only - case ($sale_maker_discount_type == 1): - $sale_maker_discount = (1 - ($sale_maker_discount / 100)); - break; - case ($sale_maker_discount_type == 0 and $display_type == true): - $sale_maker_discount = $sale_maker_discount; - break; - case ($sale_maker_discount_type == 0 and $display_type == false): - $sale_maker_discount = $sale_maker_discount; - break; - case ($sale_maker_discount_type == 2 and $display_type == true): - $sale_maker_discount = $sale_maker_discount; - break; - default: - $sale_maker_discount = 1; - break; - } - - if ($display_type == true) { - if ($sale_maker_discount != 1 and $sale_maker_discount !=0) { - switch(true) { - case ($sale_maker_discount_type == 0): - $sale_maker_discount = $currencies->format($sale_maker_discount) . ' ' . $deduction_type_array[$sale_maker_discount_type]['text']; - break; - case ($sale_maker_discount_type == 2): - $sale_maker_discount = $currencies->format($sale_maker_discount) . ' ' . $deduction_type_array[$sale_maker_discount_type]['text']; - break; - case ($sale_maker_discount_type == 1): - $sale_maker_discount = number_format( (1.00 - $sale_maker_discount),2,".","") . ' ' . $deduction_type_array[$sale_maker_discount_type]['text']; - break; - } - } else { - $sale_maker_discount = ''; - } - } - return $sale_maker_discount; -*/ - - } - -//// -// salemaker categories array - function zen_parse_salemaker_categories($clist) { - $clist_array = explode(',', $clist); - -// make sure no duplicate category IDs exist which could lock the server in a loop - $tmp_array = array(); - $n = sizeof($clist_array); - for ($i=0; $i<$n; $i++) { - if (!in_array($clist_array[$i], $tmp_array)) { - $tmp_array[] = $clist_array[$i]; - } - } - return $tmp_array; - } - -//// -// update salemaker product prices per category per product - function zen_update_salemaker_product_prices($salemaker_id) { - global $gBitDb; - $zv_categories = $gBitDb->Execute("select `sale_categories_selected` from " . TABLE_SALEMAKER_SALES . " where `sale_id` = '" . $salemaker_id . "'"); - - $za_salemaker_categories = zen_parse_salemaker_categories($zv_categories->fields['sale_categories_selected']); - $n = sizeof($za_salemaker_categories); - for ($i=0; $i<$n; $i++) { - $update_products_price = $gBitDb->Execute("select `products_id` from " . TABLE_PRODUCTS_TO_CATEGORIES . " where `categories_id`='" . $za_salemaker_categories[$i] . "'"); - while (!$update_products_price->EOF) { - zen_update_lowest_purchase_price($update_products_price->fields['products_id']); - $update_products_price->MoveNext(); - } - } - } - -?> diff --git a/includes/modules/featured_products_listing.php b/includes/modules/featured_products_listing.php index 9b5f3d84..96cc4add 100644 --- a/includes/modules/featured_products_listing.php +++ b/includes/modules/featured_products_listing.php @@ -100,12 +100,12 @@ $the_button = $link; $products_link = '' . MORE_INFO_TEXT . ''; - $display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('
', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1)); + $display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link); } else { $link = '' . MORE_INFO_TEXT . ''; $the_button = $link; $products_link = '' . MORE_INFO_TEXT . ''; - $display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('
', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1)); + $display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link); } if (PRODUCT_FEATURED_LIST_DESCRIPTION != '0') { diff --git a/includes/modules/product_listing.php b/includes/modules/product_listing.php index 7368fd26..c022e064 100644 --- a/includes/modules/product_listing.php +++ b/includes/modules/product_listing.php @@ -134,7 +134,7 @@ } $the_button = $lc_button; $products_link = '' . MORE_INFO_TEXT . ''; - $lc_text .= '
' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($listing->fields['products_id']); + $lc_text .= '
' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link); break; case 'PRODUCT_LIST_QUANTITY': diff --git a/includes/modules/products_all_listing.php b/includes/modules/products_all_listing.php index 476ecc31..a26c69c8 100644 --- a/includes/modules/products_all_listing.php +++ b/includes/modules/products_all_listing.php @@ -97,12 +97,12 @@ $the_button = $link; $products_link = '' . MORE_INFO_TEXT . ''; - $display_products_button = zen_get_buy_now_button($products_all->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($products_all->fields['products_id']) . str_repeat('
', substr(PRODUCT_ALL_BUY_NOW, 3, 1)); + $display_products_button = zen_get_buy_now_button($products_all->fields['products_id'], $the_button, $products_link); } else { $link = '' . MORE_INFO_TEXT . ''; $the_button = $link; $products_link = '' . MORE_INFO_TEXT . ''; - $display_products_button = zen_get_buy_now_button($products_all->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($products_all->fields['products_id']) . str_repeat('
', substr(PRODUCT_ALL_BUY_NOW, 3, 1)); + $display_products_button = zen_get_buy_now_button($products_all->fields['products_id'], $the_button, $products_link); } if (PRODUCT_ALL_LIST_DESCRIPTION != '0') { diff --git a/includes/modules/products_new_listing.php b/includes/modules/products_new_listing.php index 9dba7ab1..e87efc89 100644 --- a/includes/modules/products_new_listing.php +++ b/includes/modules/products_new_listing.php @@ -99,12 +99,12 @@ $the_button = $link; $products_link = '' . MORE_INFO_TEXT . ''; - $display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($products_new->fields['products_id']) . str_repeat('
', substr(PRODUCT_NEW_BUY_NOW, 3, 1)); + $display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . str_repeat('
', substr(PRODUCT_NEW_BUY_NOW, 3, 1)); } else { $link = '' . MORE_INFO_TEXT . ''; $the_button = $link; $products_link = '' . MORE_INFO_TEXT . ''; - $display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($products_new->fields['products_id']) . str_repeat('
', substr(PRODUCT_NEW_BUY_NOW, 3, 1)); + $display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . str_repeat('
', substr(PRODUCT_NEW_BUY_NOW, 3, 1)); } if (PRODUCT_NEW_LIST_DESCRIPTION != '0') { diff --git a/pages/document_product_info/document_product_info_display.php b/pages/document_product_info/document_product_info_display.php index 51892750..e703c2a2 100644 --- a/pages/document_product_info/document_product_info_display.php +++ b/pages/document_product_info/document_product_info_display.php @@ -174,7 +174,7 @@ $the_button = '' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); } else { // show the quantity box - $the_button = PRODUCTS_ORDER_QTY_TEXT . '
' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '
' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); + $the_button = PRODUCTS_ORDER_QTY_TEXT . '
' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); } echo zen_get_buy_now_button($_GET['products_id'], $the_button); ?> diff --git a/pages/product_free_shipping_info/product_free_shipping_info_display.php b/pages/product_free_shipping_info/product_free_shipping_info_display.php index 22af3a26..f5da3b8a 100644 --- a/pages/product_free_shipping_info/product_free_shipping_info_display.php +++ b/pages/product_free_shipping_info/product_free_shipping_info_display.php @@ -175,7 +175,7 @@ $the_button = '' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); } else { // show the quantity box - $the_button = PRODUCTS_ORDER_QTY_TEXT . '
' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '
' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); + $the_button = PRODUCTS_ORDER_QTY_TEXT . '
' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); } echo zen_get_buy_now_button($_GET['products_id'], $the_button); ?> diff --git a/pages/product_music_info/product_music_info_display.php b/pages/product_music_info/product_music_info_display.php index 14f9dcdb..ff3462ec 100644 --- a/pages/product_music_info/product_music_info_display.php +++ b/pages/product_music_info/product_music_info_display.php @@ -184,7 +184,7 @@ $the_button = '' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); } else { // show the quantity box - $the_button = PRODUCTS_ORDER_QTY_TEXT . '
' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '
' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); + $the_button = PRODUCTS_ORDER_QTY_TEXT . '
' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT); } echo zen_get_buy_now_button($_GET['products_id'], $the_button); ?> diff --git a/pages/product_reviews/product_reviews.php b/pages/product_reviews/product_reviews.php index 672e1b7a..6b2fe249 100644 --- a/pages/product_reviews/product_reviews.php +++ b/pages/product_reviews/product_reviews.php @@ -40,7 +40,7 @@ } $the_button = $link; $products_link = '
'; - echo zen_get_buy_now_button($review->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($review->fields['products_id']); + echo zen_get_buy_now_button($review->fields['products_id'], $the_button, $products_link); ?> diff --git a/pages/product_reviews_info/product_reviews_info.php b/pages/product_reviews_info/product_reviews_info.php index 22282a7a..4cf3fd4a 100644 --- a/pages/product_reviews_info/product_reviews_info.php +++ b/pages/product_reviews_info/product_reviews_info.php @@ -41,7 +41,7 @@ $the_button = $link; $products_link = '
'; - echo zen_get_buy_now_button($review_info->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($review_info->fields['products_id']); + echo zen_get_buy_now_button($review_info->fields['products_id'], $the_button, $products_link); ?> diff --git a/templates/list_products_inc.tpl b/templates/list_products_inc.tpl index 714c9b2e..30a5b687 100644 --- a/templates/list_products_inc.tpl +++ b/templates/list_products_inc.tpl @@ -104,7 +104,7 @@ } $the_button = $lc_button; $products_link = '' . MORE_INFO_TEXT . ''; - $lc_text .= '
' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '
' . zen_get_products_quantity_min_units_display($listing->fields['products_id']); + $lc_text .= '
' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link); break; case 'PRODUCT_LIST_IMAGE': diff --git a/templates/page_product_info.tpl b/templates/page_product_info.tpl index 43fa9048..13996b00 100644 --- a/templates/page_product_info.tpl +++ b/templates/page_product_info.tpl @@ -102,7 +102,7 @@ ({$qtyInCart} {tr}In Cart{/tr}) {/if} - {$gBitProduct->mProductsId|zen_get_products_quantity_min_units_display} + {$gBitProduct->getQuantityMinUnitsDisplay()} {/if}
From 2e429e765a88c0e12f112bf1993198bbba3a437c Mon Sep 17 00:00:00 2001 From: spiderr Date: Mon, 18 Jun 2018 10:12:55 -0400 Subject: [PATCH 04/11] remove duplicate salemaker functions from admin general.php functions --- admin/includes/functions/general.php | 33 ---------------------------- 1 file changed, 33 deletions(-) diff --git a/admin/includes/functions/general.php b/admin/includes/functions/general.php index 278b8e9a..7b4dedf2 100644 --- a/admin/includes/functions/general.php +++ b/admin/includes/functions/general.php @@ -1887,39 +1887,6 @@ function zen_orders_products_downloads($check_filename) { return $valid_downloads; } -//// -// salemaker categories array - function zen_parse_salemaker_categories($clist) { - $clist_array = explode(',', $clist); - -// make sure no duplicate category IDs exist which could lock the server in a loop - $tmp_array = array(); - $n = sizeof($clist_array); - for ($i=0; $i<$n; $i++) { - if (!in_array($clist_array[$i], $tmp_array)) { - $tmp_array[] = $clist_array[$i]; - } - } - return $tmp_array; - } - -//// -// update salemaker product prices per category per product - function zen_update_salemaker_product_prices($salemaker_id) { - global $gBitDb; - $zv_categories = $gBitDb->Execute("SELECT `sale_categories_selected` FROM " . TABLE_SALEMAKER_SALES . " WHERE `sale_id` = '" . $salemaker_id . "'"); - - $za_salemaker_categories = zen_parse_salemaker_categories($zv_categories->fields['sale_categories_selected']); - $n = sizeof($za_salemaker_categories); - for ($i=0; $i<$n; $i++) { - $update_products_price = $gBitDb->Execute("SELECT `products_id` FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE `categories_id`='" . $za_salemaker_categories[$i] . "'"); - while (!$update_products_price->EOF) { - zen_update_lowest_purchase_price($update_products_price->fields['products_id']); - $update_products_price->MoveNext(); - } - } - } - //// // check if products has discounts function zen_has_product_discounts($look_up) { From c04beb7d060f4b6b93d84394ecfef9e86ec99a39 Mon Sep 17 00:00:00 2001 From: spiderr Date: Thu, 21 Jun 2018 14:14:22 -0400 Subject: [PATCH 05/11] add default 0 for wholesale values in admin product list --- templates/admin_list_orders_inc.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/admin_list_orders_inc.tpl b/templates/admin_list_orders_inc.tpl index dfe3e87b..174434a4 100644 --- a/templates/admin_list_orders_inc.tpl +++ b/templates/admin_list_orders_inc.tpl @@ -61,26 +61,26 @@ ${$product.final_price} {if $product.products_quantity>1} : ${$finalIncome} {/if} = - {math equation="n*(x-y)" assign=wholesaleProfit n=$product.products_quantity x=$product.final_price y=$product.products_wholesale } + {math equation="n*(x-y)" assign=wholesaleProfit n=$product.products_quantity x=$product.final_price|default:0 y=$product.products_wholesale|default:0} {assign var=wholesaleProfitTotal value=$wholesaleProfitTotal+$wholesaleProfit} + {$wholesaleProfit|number_format:2} {if $gBitUser->hasPermission('p_admin')} - {math equation="n*(x-y)" assign=distributorIncome n=$product.products_quantity x=$product.products_wholesale y=$product.products_cogs} + {math equation="n*(x-y)" assign=distributorIncome n=$product.products_quantity x=$product.products_wholesale|default:0 y=$product.products_cogs|default:0} {assign var=distributorIncomeTotal value=$distributorIncomeTotal+$distributorIncome} + [{$distributorIncome|number_format:2}] {/if} {if $gBitUser->hasPermission('p_admin')} - {math equation="n*(x)" assign=cogs n=$product.products_quantity x=$product.products_cogs} + {math equation="n*(x)" assign=cogs n=$product.products_quantity x=$product.products_cogs|default:0} {assign var=cogsTotal value=$cogsTotal+$cogs} + ({$cogs|number_format:2}) {/if} {if $gBitUser->hasPermission('p_admin')} - {math equation="round( s-x-y-z, 4)" assign=auditValue s=$finalIncome x=$wholesaleProfit y=$distributorIncome z=$cogs} + {math equation="round( s-x-y-z, 4)" assign=auditValue s=$finalIncome x=$wholesaleProfit|default:0 y=$distributorIncome z=$cogs} {if $auditValue != 0} Audit error {$auditValue} From 7beeb4b14a179dac018f6abfa36d82e0c822e929 Mon Sep 17 00:00:00 2001 From: spiderr Date: Mon, 25 Jun 2018 15:11:10 -0400 Subject: [PATCH 06/11] clean up of page_product_info.tpl; add logic support for products_custom_tpl (no UI support yet) --- pages/product_info/product_info.php | 3 ++- templates/page_product_info.tpl | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pages/product_info/product_info.php b/pages/product_info/product_info.php index e6525ce8..3667f595 100644 --- a/pages/product_info/product_info.php +++ b/pages/product_info/product_info.php @@ -19,7 +19,8 @@ } define( 'HEADING_TITLE', $gBitProduct->getTitle().' - '.tra( $gBitProduct->getField( 'products_model' ) ) ); - $mid = 'bitpackage:bitcommerce/page_product_info.tpl'; + + $mid = $gBitProduct->getPreference( 'products_custom_tpl', 'bitpackage:bitcommerce/page_product_info.tpl' ); // Comments engine! if( $gCommerceSystem->getConfig( 'SHOW_PRODUCT_INFO_REVIEWS' ) ) { diff --git a/templates/page_product_info.tpl b/templates/page_product_info.tpl index 13996b00..03a9c884 100644 --- a/templates/page_product_info.tpl +++ b/templates/page_product_info.tpl @@ -5,9 +5,9 @@ {/if} {if $gBitUser->hasPermission('p_commerce_admin')} - {booticon ipackage="bitcommerce" iname="icon-pencil" iexplain="Edit Product"} - {booticon iname="icon-cogs" iexplain="Edit Product Options"} + {booticon iname="icon-check" iexplain="Edit Product Options"} {booticon iname="icon-money" iexplain="Edit Product Prices"} + {booticon ipackage="bitcommerce" iname="icon-pencil" iexplain="Edit Product"} {/if}
@@ -28,7 +28,7 @@
{if $gBitProduct->getField('products_description')} -
+
{if $smarty.const.SHOW_PRODUCT_INFO_MODEL == '1' && $gBitProduct->getField('products_model')}
@@ -46,8 +46,8 @@
{/if} -
-
+
+
{if $gBitProduct->getBasePrice() > 0}
{assign var=displayPrice value=$gBitProduct->getDisplayPrice()} From 9f87b519d133955b06ef1db7e411c6fefb139ad5 Mon Sep 17 00:00:00 2001 From: spiderr Date: Mon, 25 Jun 2018 15:11:49 -0400 Subject: [PATCH 07/11] remove code that called removed zen_get_products_sale_discount --- templates/admin_product_category_listing_inc.tpl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/templates/admin_product_category_listing_inc.tpl b/templates/admin_product_category_listing_inc.tpl index 34ecb56d..c9a40179 100644 --- a/templates/admin_product_category_listing_inc.tpl +++ b/templates/admin_product_category_listing_inc.tpl @@ -17,12 +17,10 @@ {tr}ID{/tr} {tr}Categories{/tr} - {tr}Special{/tr}/{tr}Sale{/tr} {tr}Quantity{/tr} {tr}Status{/tr} {tr}Sort Order{/tr} - - + {foreach from=$catList key=catId item=category} {assign var=catPath value=$catId|zen_get_path} @@ -30,7 +28,6 @@ {$catId} {booticon iname="icon-folder-close"} {$category.categories_name} - {0|zen_get_products_sale_discount:$catId:TRUE} {$category.total_products_on} {tr}of{/tr} {$category.total_products} {tr}active{/tr} {if $category.categories_status == '1'} From 778e1e7abf7926787398e9f155a3577478cf839a Mon Sep 17 00:00:00 2001 From: spiderr Date: Mon, 25 Jun 2018 15:13:00 -0400 Subject: [PATCH 08/11] wrap default template with gBitProduct css styling --- includes/templates/template_default/common/tpl_main_page.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/templates/template_default/common/tpl_main_page.php b/includes/templates/template_default/common/tpl_main_page.php index 83f10d49..899043dd 100644 --- a/includes/templates/template_default/common/tpl_main_page.php +++ b/includes/templates/template_default/common/tpl_main_page.php @@ -22,6 +22,8 @@ $header_template = 'tpl_header.php'; $footer_template = 'tpl_footer.php'; +print '
'; require($template->get_template_dir('/tpl_products_next_previous.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_products_next_previous.php'); require($body_code); require(DIR_FS_MODULES . 'footer.php'); +print '
'; From 91451ea8965c64841ebababe2e0eddc3b720e64d Mon Sep 17 00:00:00 2001 From: spiderr Date: Mon, 25 Jun 2018 15:14:05 -0400 Subject: [PATCH 09/11] wrap error/info_message with css .alert --- includes/templates/template_default/common/tpl_header.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/templates/template_default/common/tpl_header.php b/includes/templates/template_default/common/tpl_header.php index ebec3eba..fc6969da 100644 --- a/includes/templates/template_default/common/tpl_header.php +++ b/includes/templates/template_default/common/tpl_header.php @@ -21,9 +21,8 @@ // ?> -

+

-

+

- From eb31a29a746772c174d958fd10fa1940f1724139 Mon Sep 17 00:00:00 2001 From: spiderr Date: Mon, 25 Jun 2018 16:12:59 -0400 Subject: [PATCH 10/11] add com_porducts_atttributes.products_options_values_comment --- admin/schema_inc.php | 1 + classes/CommerceProduct.php | 11 +++-- classes/CommerceProductManager.php | 1 + ...admin_products_options_values_edit_inc.tpl | 44 +++++++++++-------- templates/product_options_inc.tpl | 10 ++--- 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 05115cec..57834bdf 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -316,6 +316,7 @@ products_options_id I4 NOTNULL, products_attributes_id I4 NOTNULL AUTO, products_options_values_name C(128), + products_options_values_comment C(256), options_values_price N(15,4), options_values_wholesale N(15,4), options_values_cogs N(15,4), diff --git a/classes/CommerceProduct.php b/classes/CommerceProduct.php index 73615565..b571011f 100644 --- a/classes/CommerceProduct.php +++ b/classes/CommerceProduct.php @@ -1893,7 +1893,7 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $products_options_details = $vals['products_options_values_name']; } else { // don't show option value name on TEXT or filename - $products_options_details = ''; + $products_options_details = '
'.$vals['products_options_values_name'].'
'; } if ($this->mOptions[$optionsId]['products_options_images_style'] >= 3) { $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight . '
' : ''); @@ -2108,6 +2108,9 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $productOptions[$optionsId]['option_values'][$valId]['value_name'] = $vals['products_options_values_name']; $productOptions[$optionsId]['option_values'][$valId]['value_price'] = $vals['value_price']; + if( $vals['products_options_values_comment'] ) { + $tmp_html .= '
'.$vals['products_options_values_comment'].'
'; + } // default // find default attribute if set to for default dropdown @@ -2121,11 +2124,7 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting switch (true) { // text case ($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT): - if ($productSettings['show_attributes_qty_prices_icon'] == 'true') { - $productOptions[$optionsId]['name'] = ATTRIBUTES_QTY_PRICE_SYMBOL . $this->mOptions[$optionsId]['products_options_name']; - } else { - $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; - } + $productOptions[$optionsId]['name'] = $this->mOptions[$optionsId]['products_options_name']; $productOptions[$optionsId]['menu'] = $tmp_html; $productOptions[$optionsId]['comment'] = $this->mOptions[$optionsId]['products_options_comment']; $productOptions[$optionsId]['comment_position'] = $commentPosition; diff --git a/classes/CommerceProductManager.php b/classes/CommerceProductManager.php index ff82acda..08b42687 100644 --- a/classes/CommerceProductManager.php +++ b/classes/CommerceProductManager.php @@ -123,6 +123,7 @@ function verifyOptionsValue( &$pParamHash ) { 'products_attributes_wt', 'products_attributes_wt_pfix', 'products_options_values_name', + 'products_options_values_comment', 'attributes_price_onetime', 'attributes_price_factor', 'attributes_pf_offset', diff --git a/templates/admin_products_options_values_edit_inc.tpl b/templates/admin_products_options_values_edit_inc.tpl index f555254d..5e467c8c 100644 --- a/templates/admin_products_options_values_edit_inc.tpl +++ b/templates/admin_products_options_values_edit_inc.tpl @@ -1,6 +1,6 @@
-
{tr}Option Value Id{/tr}
+ {formlabel label="Option Value Id"} {forminput} {if $editValue.products_options_values_id} {$editValue.products_options_values_id} @@ -11,12 +11,20 @@
-
{tr}Options Name{/tr}
+ {formlabel label="Options Name"}
 
+ +
+ {formlabel label="Comment"} + {forminput} + + {formhelp note="A small help-block will be shown below this selection"} + {/forminput} +
-
{tr}Option{/tr}
+ {formlabel label="Option"}
 
-
{tr}Related Group ID{/tr}
+ {formlabel label="Related Group ID"}
{html_options class="form-control" name="purchase_group_id" options=$groupList selected=$editValue.purchase_group_id} {formhelp note="User will be added to this group upon successful purchase"}
@@ -43,7 +51,7 @@ {legend legend="Attribute Pricing"}
-
{tr}Fixed Attribute Price{/tr}
+ {formlabel label="Fixed Attribute Price"}
 
{if $gCommerceSystem->getConfig('ATTRIBUTES_ENABLED_PRICE_FACTOR') == 'true'}
-
{tr}% Attribute Price{/tr}
+ {formlabel label="% Attribute Price"}
-
{tr}Offset{/tr}
+ {formlabel label="Offset"}
 
-
{tr}One Time Factor{/tr}
+ {formlabel label="One Time Factor"}
-
{tr}Offset{/tr}
+ {formlabel label="Offset"}
{/if} @@ -83,11 +91,11 @@ {if $gCommerceSystem->getConfig('ATTRIBUTES_ENABLED_QTY_PRICES') == 'true'} {legend legend="Attribute Quantity Pricing"}
-
{tr}Option Qty Price Discount{/tr}
+ {formlabel label="Option Qty Price Discount"}
-
{tr}Onetime Option Qty Price Discount{/tr}
+ {formlabel label="Onetime Option Qty Price Discount"}
{/legend} @@ -96,19 +104,19 @@ {if $gCommerceSystem->getConfig('ATTRIBUTES_ENABLED_TEXT_PRICES') == 'true'} {legend legend="Attribute Text Pricing"}
-
{tr}Price Per Word{/tr}
+ {formlabel label="Price Per Word"}
-
{tr}- Free Words{/tr}
+ {formlabel label="- Free Words"}
-
{tr}Price Per Letter{/tr}
+ {formlabel label="Price Per Letter"}
-
{tr}- Free Letters{/tr}
+ {formlabel label="- Free Letters"}
{/legend} @@ -116,7 +124,7 @@ {legend legend="Attribute Weights"}
-
{tr}Weight{/tr}
+ {formlabel label="Weight"}
'; + $tmp_html = ' '; $tmp_html .= $products_options_details; break; } @@ -431,7 +428,7 @@ } else { $tmp_value = $gBitCustomer->mCart->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']]; - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; $tmp_word_cnt_string = ''; // calculate word charges diff --git a/admin/includes/functions/general.php b/admin/includes/functions/general.php index 7b4dedf2..45178fec 100644 --- a/admin/includes/functions/general.php +++ b/admin/includes/functions/general.php @@ -322,18 +322,6 @@ function zen_get_geo_zone_name($geo_zone_id) { } - function zen_get_uprid($prid, $params) { - $uprid = $prid; - if ( (is_array($params)) && (!strstr($prid, '{')) ) { - while (list($option, $value) = each($params)) { - $uprid = $uprid . '{' . $option . '}' . $value; - } - } - - return $uprid; - } - - function zen_get_orders_status_name($orders_status_id, $language_id = '') { global $gBitDb; @@ -1482,43 +1470,6 @@ function zen_admin_demo() { return $demo_on; } -//// -// - function zen_has_product_attributes_downloads($products_id, $check_valid=false) { - global $gBitDb; - if (DOWNLOAD_ENABLED == 'true') { - $download_display_query_raw ="SELECT pa.`products_attributes_id`, pad.`products_attributes_filename` - FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa - INNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON(pa.`products_options_values_id`=pom.`products_options_values_id`) - INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON(pad.`products_attributes_id`= pa.`products_attributes_id`) - WHERE pom.`products_id`=?"; - $download_display = $gBitDb->query( $download_display_query_raw, array( $products_id ) ); - if ($check_valid == true) { - $valid_downloads = ''; - while (!$download_display->EOF) { - // Could go into /admin/includes/configure.php - // define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/'); - if (!file_exists(DIR_FS_CATALOG . 'download/' . $download_display->fields['products_attributes_filename'])) { - $valid_downloads .= '
  ' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif') . ' Invalid: ' . $download_display->fields['products_attributes_filename']; - // break; - } else { - $valid_downloads .= '
  ' . zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') . ' Valid  : ' . $download_display->fields['products_attributes_filename']; - } - $download_display->MoveNext(); - } - } else { - if ($download_display->RecordCount() != 0) { - $valid_downloads = $download_display->RecordCount() . ' files'; - } else { - $valid_downloads = 'none'; - } - } - } else { - $valid_downloads = 'disabled'; - } - return $valid_downloads; - } - //// // Count how many subcategories exist in a category // TABLES: categories diff --git a/admin/inserts.sql b/admin/inserts.sql index 3f2a6f6a..24e78251 100644 --- a/admin/inserts.sql +++ b/admin/inserts.sql @@ -196,7 +196,6 @@ "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Display Multiple Products Qty Box Status and Set Button Location', 'PRODUCT_LISTING_MULTIPLE_ADD_TO_CART', '3', 'Do you want to display Add Multiple Products Qty Box and Set Button Location?
0= off
1= Top
2= Bottom
3= Both', '8', '25', 'zen_cfg_select_option(array('0', '1', '2', '3'), ', now())", "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Display Product Description', 'PRODUCT_LIST_DESCRIPTION', '150', 'Do you want to display the Product Description?

0= OFF
150= Suggested Length, or enter the maximum number of characters to display', '8', '30', now())", "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Check stock level', 'STOCK_CHECK', 'true', 'Check to see if sufficent stock is available', '9', '1', 'zen_cfg_select_option(array('true', 'false'), ', now())", -"INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Subtract stock', 'STOCK_LIMITED', 'true', 'Subtract product in stock by product orders', '9', '2', 'zen_cfg_select_option(array('true', 'false'), ', now())", "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Allow Checkout', 'STOCK_ALLOW_CHECKOUT', 'true', 'Allow customer to checkout even if there is insufficient stock', '9', '3', 'zen_cfg_select_option(array('true', 'false'), ', now())", "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Mark product out of stock', 'STOCK_MARK_PRODUCT_OUT_OF_STOCK', '***', 'Display something on screen so customer can see which product has insufficient stock', '9', '4', now())", "INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Stock Re-order level', 'STOCK_REORDER_LEVEL', '5', 'Define when stock needs to be re-ordered', '9', '5', now())", diff --git a/admin/languages.php b/admin/languages.php index 345a6571..aa2f62ee 100644 --- a/admin/languages.php +++ b/admin/languages.php @@ -82,7 +82,7 @@ // create additional products_options records $products_options = $gBitDb->Execute("select `products_options_id`, `products_options_name`, - `products_options_sort_order`, `products_options_type`, `products_options_length`, `products_options_comment`, `products_options_size`, + `products_options_sort_order`, `products_options_type`, `products_options_length`, `products_options_comment`, `products_options_images_per_row`, `products_options_images_style` from " . TABLE_PRODUCTS_OPTIONS . " where `language_id` = '" . (int)$_SESSION['languages_id'] . "'"); @@ -90,7 +90,7 @@ while (!$products_options->EOF) { $gBitDb->Execute("insert into " . TABLE_PRODUCTS_OPTIONS . " (`products_options_id`, `language_id`, `products_options_name`, - `products_options_sort_order`, `products_options_type`, `products_options_length`, `products_options_comment`, `products_options_size`, `products_options_images_per_row`, `products_options_images_style`) + `products_options_sort_order`, `products_options_type`, `products_options_length`, `products_options_comment`, `products_options_images_per_row`, `products_options_images_style`) values ('" . (int)$products_options->fields['products_options_id'] . "', '" . (int)$insert_id . "', '" . zen_db_input($products_options->fields['products_options_name']) . "', @@ -98,7 +98,6 @@ '" . zen_db_input($products_options->fields['products_options_type']) . "', '" . zen_db_input($products_options->fields['products_options_length']) . "', '" . zen_db_input($products_options->fields['products_options_comment']) . "', - '" . zen_db_input($products_options->fields['products_options_size']) . "', '" . zen_db_input($products_options->fields['products_options_images_per_row']) . "', '" . zen_db_input($products_options->fields['products_options_images_style']) . "')"); diff --git a/admin/product.php b/admin/product.php index 82ddb165..a2de47f6 100644 --- a/admin/product.php +++ b/admin/product.php @@ -261,7 +261,6 @@ '' . zen_image_button('button_preview.gif', IMAGE_PREVIEW) . '' . '  ' . '' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '' . '

'); - $contents[] = array('align' => 'left', 'text' => '
' . '' . TEXT_PRODUCT_ATTRIBUTES_DOWNLOADS . '' . zen_has_product_attributes_downloads($gBitProduct->getField( 'products_id' )) . zen_has_product_attributes_downloads($gBitProduct->getField( 'products_id' ), true)); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_DELETE . '' . zen_get_products_name($gBitProduct->getField( 'products_id' )) . ' ID# ' . $gBitProduct->getField( 'products_id' ) . '
' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_UPDATES . '' . zen_get_products_name($gBitProduct->getField( 'products_id' ), $languages_id) . ' ID# ' . $gBitProduct->getField( 'products_id' ) . '
' . zen_image_button('button_update.gif', IMAGE_UPDATE) . ''); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_PRODUCT . '' . zen_get_products_name($gBitProduct->getField( 'products_id' ), $languages_id) . ' ID# ' . $gBitProduct->getField( 'products_id' ) . '
' . zen_image_button('button_copy_to.gif', IMAGE_COPY_TO) . ''); diff --git a/admin/product_free_shipping.php b/admin/product_free_shipping.php index 620c9a00..89832427 100644 --- a/admin/product_free_shipping.php +++ b/admin/product_free_shipping.php @@ -262,7 +262,6 @@ '' . zen_image_button('button_preview.gif', IMAGE_PREVIEW) . '' . '  ' . '' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '' . '

'); - $contents[] = array('align' => 'left', 'text' => '
' . '' . TEXT_PRODUCT_ATTRIBUTES_DOWNLOADS . '' . zen_has_product_attributes_downloads($pInfo->products_id) . zen_has_product_attributes_downloads($pInfo->products_id, true)); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_DELETE . '' . zen_get_products_name($pInfo->products_id) . ' ID# ' . $pInfo->products_id . '
' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_UPDATES . '' . zen_get_products_name($pInfo->products_id, $languages_id) . ' ID# ' . $pInfo->products_id . '
' . zen_image_button('button_update.gif', IMAGE_UPDATE) . ''); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_PRODUCT . '' . zen_get_products_name($pInfo->products_id, $languages_id) . ' ID# ' . $pInfo->products_id . '
' . zen_image_button('button_copy_to.gif', IMAGE_COPY_TO) . ''); diff --git a/admin/product_music.php b/admin/product_music.php index 59debd6b..8b947fe3 100644 --- a/admin/product_music.php +++ b/admin/product_music.php @@ -263,7 +263,6 @@ '' . zen_image_button('button_preview.gif', IMAGE_PREVIEW) . '' . '  ' . '' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '' . '

'); - $contents[] = array('align' => 'left', 'text' => '
' . '' . TEXT_PRODUCT_ATTRIBUTES_DOWNLOADS . '' . zen_has_product_attributes_downloads($pInfo->products_id) . zen_has_product_attributes_downloads($pInfo->products_id, true)); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_DELETE . '' . zen_get_products_name($pInfo->products_id) . ' ID# ' . $pInfo->products_id . '
' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_UPDATES . '' . zen_get_products_name($pInfo->products_id, $languages_id) . ' ID# ' . $pInfo->products_id . '
' . zen_image_button('button_update.gif', IMAGE_UPDATE) . ''); $contents[] = array('align' => 'left', 'text' => '
' . TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_PRODUCT . '' . zen_get_products_name($pInfo->products_id, $languages_id) . ' ID# ' . $pInfo->products_id . '
' . zen_image_button('button_copy_to.gif', IMAGE_COPY_TO) . ''); diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 57834bdf..673c7aaa 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -294,7 +294,8 @@ BITCOMMERCE_INSTALL_PREFIX.'com_products_options_types' => " products_options_types_id I4, - products_options_types_name C(32) + products_options_types_name C(32), + products_options_types_description X ", BITCOMMERCE_INSTALL_PREFIX.'com_products_options' => " @@ -303,9 +304,8 @@ products_options_name C(32), products_options_sort_order I4, products_options_type I2, - products_options_length I2 NOTNULL default '32', + products_options_length I2 NOTNULL default '64', products_options_comment C(64), - products_options_size I2 NOTNULL default '32', products_options_images_per_row I2 default '5', products_options_images_style I1 default '0', products_options_html_attrib X @@ -553,7 +553,7 @@ customers_basket_id I4 NOTNULL, products_options_id I4 NOTNULL, products_options_values_id I4, - products_options_value_text C(64) + products_options_value_text X CONSTRAINT ', CONSTRAINT `cust_bask_att_bask_ref` FOREIGN KEY ( `customers_basket_id` ) REFERENCES `".BITCOMMERCE_DB_PREFIX."com_customers_basket`( `customers_basket_id` )' ", @@ -1484,7 +1484,6 @@ class C(32), "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('Display Multiple Products Qty Box Status and Set Button Location', 'PRODUCT_LISTING_MULTIPLE_ADD_TO_CART', '3', 'Do you want to display Add Multiple Products Qty Box and Set Button Location?
0= off
1= Top
2= Bottom
3= Both', '8', '25', 'zen_cfg_select_option(array(''0'', ''1'', ''2'', ''3''), ', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `date_added`) VALUES ('Display Product Description', 'PRODUCT_LIST_DESCRIPTION', '150', 'Do you want to display the Product Description?

0= OFF
150= Suggested Length, or enter the maximum number of characters to display', '8', '30', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('Check stock level', 'STOCK_CHECK', 'true', 'Check to see if sufficent stock is available', '9', '1', 'zen_cfg_select_option(array(''true'', ''false''), ', 'NOW')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('Subtract stock', 'STOCK_LIMITED', 'true', 'Subtract product in stock by product orders', '9', '2', 'zen_cfg_select_option(array(''true'', ''false''), ', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `set_function`, `date_added`) VALUES ('Allow Checkout', 'STOCK_ALLOW_CHECKOUT', 'true', 'Allow customer to checkout even if there is insufficient stock', '9', '3', 'zen_cfg_select_option(array(''true'', ''false''), ', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `date_added`) VALUES ('Mark product out of stock', 'STOCK_MARK_PRODUCT_OUT_OF_STOCK', '***', 'Display something on screen so customer can see which product has insufficient stock', '9', '4', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `date_added`) VALUES ('Stock Re-order level', 'STOCK_REORDER_LEVEL', '5', 'Define when stock needs to be re-ordered', '9', '5', 'NOW')", @@ -1821,15 +1820,27 @@ class C(32), "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_product_types` ( `type_name`, `type_handler`, `type_master_type`, `allow_add_to_cart`, `date_added`, `last_modified` ) VALUES ('Document - General', 'document_general', '3', 'N', 'NOW', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_product_types` ( `type_name`, `type_handler`, `type_master_type`, `allow_add_to_cart`, `date_added`, `last_modified` ) VALUES ('Document - Product', 'document_product', '3', 'Y', 'NOW', 'NOW')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_product_types` ( `type_name`, `type_handler`, `type_master_type`, `allow_add_to_cart`, `date_added`, `last_modified` ) VALUES ('Product - Free Shipping', 'product_free_shipping', '1', 'Y', 'NOW', 'NOW')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`) VALUES (0, 'Dropdown')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`) VALUES (1, 'Text')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`) VALUES (2, 'Radio')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`) VALUES (3, 'Checkbox')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`) VALUES (4, 'File')", -"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`) VALUES (5, 'Read Only')", -//Disable for now, default TEXT option is needed for text lettering on some products. This brute force hack is crude. Will fix later. xoxo - spiderr -//"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_attributes` (`products_options_values_id`, `products_options_values_name`) VALUES (0, 'TEXT')", - +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (0, 'Dropdown', '')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (1, 'Text', '')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (2, 'Radio', '')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (3, 'Checkbox', '')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (4, 'File', '')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (5, 'Read Only', '')", + +/* +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (6, 'number', 'Defines a field for entering a number')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (7, 'range', 'Defines a range control (like a slider control)')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (8, 'color', 'Defines a color picker')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (9, 'date', 'Defines a date control (year, month, day (no time))')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (10, 'datetime-local', 'Defines a date and time control (year, month, day, time (no timezone)')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (11, 'time', 'Defines a control for entering a time (no timezone)')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (12, 'week', 'Defines a week and year control (no timezone)')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (13, 'month', 'Defines a month and year control (no timezone)')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (14, 'url', 'Defines a field for entering a URL')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (15, 'email', 'Defines a field for an e-mail address')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (16, 'password', 'Defines a password field')", +"INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_products_options_types` (`products_options_types_id`, `products_options_types_name`, `products_options_types_description`) VALUES (17, 'tel', 'Defines a field for entering a telephone number')", +*/ "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_countries` VALUES (1,'Afghanistan', 'AF', 'AFG', '4', '1')", "INSERT INTO `".BITCOMMERCE_DB_PREFIX."com_countries` VALUES (2,'Albania', 'AL', 'ALB', '8', '1')", diff --git a/classes/CommerceOrder.php b/classes/CommerceOrder.php index 2debcee5..6e6a6554 100644 --- a/classes/CommerceOrder.php +++ b/classes/CommerceOrder.php @@ -699,31 +699,30 @@ function cart() { 'format_id' => $billingAddress['address_format_id']); } - foreach( array_keys( $gBitCustomer->mCart->contents ) as $productsKey ) { - $this->contents[$productsKey] = $gBitCustomer->mCart->getProductHash( $productsKey ); + foreach( array_keys( $gBitCustomer->mCart->contents ) as $cartItemKey ) { + $this->contents[$cartItemKey] = $gBitCustomer->mCart->getProductHash( $cartItemKey ); if( !empty( $taxAddress ) ) { - $this->contents[$productsKey]['tax'] = zen_get_tax_rate( $this->contents[$productsKey]['tax_class_id'], $taxAddress['entry_country_id'], $taxAddress['entry_zone_id'] ); - $this->contents[$productsKey]['tax_description'] = zen_get_tax_description( $this->contents[$productsKey]['tax_class_id'], $taxAddress['entry_country_id'], $taxAddress['entry_zone_id'] ); + $this->contents[$cartItemKey]['tax'] = zen_get_tax_rate( $this->contents[$cartItemKey]['tax_class_id'], $taxAddress['entry_country_id'], $taxAddress['entry_zone_id'] ); + $this->contents[$cartItemKey]['tax_description'] = zen_get_tax_description( $this->contents[$cartItemKey]['tax_class_id'], $taxAddress['entry_country_id'], $taxAddress['entry_zone_id'] ); } - if ( !empty( $this->contents[$productsKey]['attributes'] ) ) { - $attributes = $this->contents[$productsKey]['attributes']; - $this->contents[$productsKey]['attributes'] = array(); + if ( !empty( $this->contents[$cartItemKey]['attributes'] ) ) { + $attributes = $this->contents[$cartItemKey]['attributes']; + $this->contents[$cartItemKey]['attributes'] = array(); $subindex = 0; - foreach( $attributes as $option=>$value ) { - $optionValues = zen_get_option_value( zen_get_options_id( $option ), (int)$value ); + foreach( $attributes as $optionKey=>$value ) { + list( $optionId, $keyValueId ) = explode( '=', $optionKey ); + $optionValues = zen_get_option_value( $optionId, (int)$value ); // Determine if attribute is a text attribute and change products array if it is. - if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){ - $attr_value = $this->contents[$productsKey]['attributes_values'][$option]; - } else { - $attr_value = $optionValues['products_options_values_name']; + $attrValue = $optionValues['products_options_values_name']; + if( !empty( $this->contents[$cartItemKey]['attributes_values'][$optionKey] ) ) { + $attrValue .= '
'. $this->contents[$cartItemKey]['attributes_values'][$optionKey] . '
'; } - $this->contents[$productsKey]['attributes'][$subindex] = array('option' => $optionValues['products_options_name'], - 'value' => $attr_value, - 'options_id' => $option, + $this->contents[$cartItemKey]['attributes'][$subindex] = array('option' => $optionValues['products_options_name'], + 'value' => $attrValue, + 'options_id' => $optionId, 'options_values_id' => $value, - 'option_id' => $option, 'value_id' => $value, 'prefix' => $optionValues['price_prefix'], 'price' => $optionValues['options_values_price']); @@ -732,12 +731,12 @@ function cart() { } } - $shown_price = (zen_add_tax($this->contents[$productsKey]['final_price'], $this->contents[$productsKey]['tax']) * $this->contents[$productsKey]['products_quantity']) - + zen_add_tax($this->contents[$productsKey]['onetime_charges'], $this->contents[$productsKey]['tax']); + $shown_price = (zen_add_tax($this->contents[$cartItemKey]['final_price'], $this->contents[$cartItemKey]['tax']) * $this->contents[$cartItemKey]['products_quantity']) + + zen_add_tax($this->contents[$cartItemKey]['onetime_charges'], $this->contents[$cartItemKey]['tax']); $this->subtotal += $shown_price; - $products_tax = $this->contents[$productsKey]['tax']; - $products_tax_description = $this->contents[$productsKey]['tax_description']; + $products_tax = $this->contents[$cartItemKey]['tax']; + $products_tax_description = $this->contents[$cartItemKey]['tax_description']; if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); if (isset($this->info['tax_groups']["$products_tax_description"])) { @@ -954,94 +953,61 @@ private function createAddProducts($pOrdersId) { // 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 - FROM " . TABLE_PRODUCTS . " p - LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON(p.`products_id`=pom.`products_id`) - LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON (pa.`products_options_values_id`=pom.`products_options_values_id`) - LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON(pa.`products_options_values_id`=pad.`products_options_values_id`) - WHERE 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 = $this->mDb->GetRow($stock_query_raw, $bindVars); - } else { - $stockValues = $this->mDb->GetRow( "SELECT `products_quantity` FROM " . TABLE_PRODUCTS . " WHERE `products_id` = ?", array( zen_get_prid($this->contents[$productsKey]['id']) ) ); - } + foreach( array_keys( $this->contents ) as $cartItemKey ) { + $stockQty = $this->mDb->GetOne( "SELECT `products_quantity` FROM " . TABLE_PRODUCTS . " WHERE `products_id` = ?", array( zen_get_prid($this->contents[$cartItemKey]['id']) ) ); - if ( !empty( $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']; - - $this->mDb->query("update " . TABLE_PRODUCTS . " set `products_quantity` = ? where `products_id` = ?", array( $stock_left, 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') { - $this->mDb->query("update " . TABLE_PRODUCTS . " set `products_status` = '0' where `products_id` = ?", array( zen_get_prid($this->contents[$productsKey]['id']) ) ); - } + if ( $stockQty ) { +// $this->contents[$cartItemKey]['stock_value'] = $stockValues['products_quantity']; + $this->mDb->query("update " . TABLE_PRODUCTS . " set `products_quantity` = ? where `products_id` = ?", array( $stockQty, zen_get_prid($this->contents[$cartItemKey]['id']) ) ); + if ($stockQty < 1) { // && (STOCK_ALLOW_CHECKOUT == 'false') ) + // only set status to off when not displaying sold out + if (SHOW_PRODUCTS_SOLD_OUT == '0') { + $this->mDb->query("update " . TABLE_PRODUCTS . " set `products_status` = '0' where `products_id` = ?", array( zen_get_prid($this->contents[$cartItemKey]['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"; - } + // for low stock email + if ( $stockQty <= STOCK_REORDER_LEVEL ) { + // WebMakers.com Added: add to low stock email + $this->email_low_stock .= 'ID# ' . zen_get_prid($this->contents[$cartItemKey]['id']) . "\t\t" . $this->contents[$cartItemKey]['model'] . "\t\t" . $this->contents[$cartItemKey]['name'] . "\t\t" . ' Qty Left: ' . $stock_left . "\n"; } } // Update products_ordered (for bestsellers list) - $this->mDb->query( "UPDATE " . TABLE_PRODUCTS . " SET `products_ordered` = `products_ordered` + ? WHERE `products_id` = ?", array( sprintf('%f', $this->contents[$productsKey]['products_quantity'] ), zen_get_prid( $this->contents[$productsKey]['id'] ) ) ); + $this->mDb->query( "UPDATE " . TABLE_PRODUCTS . " SET `products_ordered` = `products_ordered` + ? WHERE `products_id` = ?", array( sprintf('%f', $this->contents[$cartItemKey]['products_quantity'] ), zen_get_prid( $this->contents[$cartItemKey]['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']); + 'products_id' => zen_get_prid($this->contents[$cartItemKey]['id']), + 'products_model' => $this->contents[$cartItemKey]['model'], + 'products_name' => $this->contents[$cartItemKey]['name'], + 'products_price' => $this->contents[$cartItemKey]['price'], + 'products_cogs' => $this->contents[$cartItemKey]['products_cogs'], + 'products_wholesale' => $this->contents[$cartItemKey]['products_wholesale'], + 'products_commission' => $this->contents[$cartItemKey]['commission'], + 'final_price' => $this->contents[$cartItemKey]['final_price'], + 'onetime_charges' => $this->contents[$cartItemKey]['onetime_charges'], + 'products_tax' => $this->contents[$cartItemKey]['tax'], + 'products_quantity' => $this->contents[$cartItemKey]['products_quantity'], + 'products_priced_by_attribute' => $this->contents[$cartItemKey]['products_priced_by_attribute'], + 'product_is_free' => $this->contents[$cartItemKey]['product_is_free'], + 'products_discount_type' => $this->contents[$cartItemKey]['products_discount_type'], + 'products_discount_type_from' => $this->contents[$cartItemKey]['products_discount_type_from']); $this->mDb->associateInsert(TABLE_ORDERS_PRODUCTS, $sql_data_array); - $this->contents[$productsKey]['orders_products_id'] = zen_db_insert_id( TABLE_ORDERS_PRODUCTS, 'orders_products_id' ); + $this->contents[$cartItemKey]['orders_products_id'] = zen_db_insert_id( TABLE_ORDERS_PRODUCTS, 'orders_products_id' ); - $this->otUpdateCreditAccount( $productsKey );//ICW ADDED FOR CREDIT CLASS SYSTEM + $this->otUpdateCreditAccount( $cartItemKey ); - if( !empty( $this->contents[$productsKey]['purchase_group_id'] ) ) { - $gBitUser->addUserToGroup( $gBitUser->mUserId, $this->contents[$productsKey]['purchase_group_id'] ); + if( !empty( $this->contents[$cartItemKey]['purchase_group_id'] ) ) { + $gBitUser->addUserToGroup( $gBitUser->mUserId, $this->contents[$cartItemKey]['purchase_group_id'] ); } //------insert customer choosen option to order-------- $attributes_exist = '0'; $this->products_ordered_attributes = ''; - if( !empty($this->contents[$productsKey]['attributes']) ) { + if( !empty($this->contents[$cartItemKey]['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'] ); + foreach( array_keys( $this->contents[$cartItemKey]['attributes'] ) as $j ) { + $optionValues = zen_get_option_value( (int)$this->contents[$cartItemKey]['attributes'][$j]['options_id'], (int)$this->contents[$cartItemKey]['attributes'][$j]['value_id'] ); if( !empty( $optionValues['purchase_group_id'] ) ) { $gBitUser->addUserToGroup( $gBitUser->mUserId, $optionValues['purchase_group_id'] ); } @@ -1049,9 +1015,9 @@ private function createAddProducts($pOrdersId) { 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'], + 'orders_products_id' => $this->contents[$cartItemKey]['orders_products_id'], 'products_options' => $optionValues['products_options_name'], - 'products_options_values' => $this->contents[$productsKey]['attributes'][$j]['value'], + 'products_options_values' => $this->contents[$cartItemKey]['attributes'][$j]['value'], 'options_values_price' => $optionValues['options_values_price'], 'options_values_cogs' => $optionValues['options_values_cogs'], 'options_values_wholesale' => $optionValues['options_values_wholesale'], @@ -1075,36 +1041,28 @@ private function createAddProducts($pOrdersId) { 'products_options_id' => $optionValues['products_options_id'], 'products_options_values_id' => $optionValues['products_options_values_id'], ); + $this->mDb->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']); - - $this->mDb->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']); + $this->products_ordered_attributes .= "\n\t" . $optionValues['products_options_name'] . ' ' . zen_decode_specialchars($this->contents[$cartItemKey]['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_weight += ($this->contents[$cartItemKey]['products_quantity'] * $this->contents[$cartItemKey]['weight']); +// $this->total_tax += zen_calculate_tax($total_products_price, $products_tax) * $this->contents[$cartItemKey]['products_quantity']; // $this->total_cost += $total_products_price; $this->products_ordered_html .= '' . - '' . $this->contents[$productsKey]['products_quantity'] . ' x' . - '' . $this->contents[$productsKey]['name'] . ($this->contents[$productsKey]['model'] != '' ? ' (' . $this->contents[$productsKey]['model'] . ') ' : '') . + '' . $this->contents[$cartItemKey]['products_quantity'] . ' x' . + '' . $this->contents[$cartItemKey]['name'] . ($this->contents[$cartItemKey]['model'] != '' ? ' (' . $this->contents[$cartItemKey]['model'] . ') ' : '') . ' '. $this->products_ordered_attributes .'' . '' . - $currencies->display_price($this->contents[$productsKey]['final_price'], $this->contents[$productsKey]['tax'], $this->contents[$productsKey]['products_quantity']) . - ($this->contents[$productsKey]['onetime_charges'] !=0 ? + $currencies->display_price($this->contents[$cartItemKey]['final_price'], $this->contents[$cartItemKey]['tax'], $this->contents[$cartItemKey]['products_quantity']) . + ($this->contents[$cartItemKey]['onetime_charges'] !=0 ? '' . TEXT_ONETIME_CHARGES_EMAIL . '' . - '' . $currencies->display_price($this->contents[$productsKey]['onetime_charges'], $this->contents[$productsKey]['tax'], 1) : '') . + '' . $currencies->display_price($this->contents[$cartItemKey]['onetime_charges'], $this->contents[$cartItemKey]['tax'], 1) : '') . ''; } @@ -1194,12 +1152,12 @@ function sendOrderEmail( $pEmailRecipient=NULL, $pFormat=NULL ) { //products area $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n"; - foreach( array_keys( $this->contents ) as $productsKey ) { - $email_order .= $this->contents[$productsKey]['products_quantity'] . ' x ' . $this->contents[$productsKey]['name'] . ($this->contents[$productsKey]['model'] != '' ? ' (' . $this->contents[$productsKey]['model'] . ') ' : '') . ' = ' . - $currencies->display_price( $this->contents[$productsKey]['final_price'], $this->contents[$productsKey]['tax'], $this->contents[$productsKey]['products_quantity'], $this->getField( 'currency' ), $this->getField( 'currency_value' ) ) . - ($this->contents[$productsKey]['onetime_charges'] !=0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->contents[$productsKey]['onetime_charges'], $this->contents[$productsKey]['tax'], 1) : ''); - foreach( array_keys( $this->contents[$productsKey]['attributes'] ) as $j ) { - $email_order .= "\n + " . zen_decode_specialchars($this->contents[$productsKey]['attributes'][$j]['option']) . ' ' . zen_decode_specialchars($this->contents[$productsKey]['attributes'][$j]['value']); + foreach( array_keys( $this->contents ) as $cartItemKey ) { + $email_order .= $this->contents[$cartItemKey]['products_quantity'] . ' x ' . $this->contents[$cartItemKey]['name'] . ($this->contents[$cartItemKey]['model'] != '' ? ' (' . $this->contents[$cartItemKey]['model'] . ') ' : '') . ' = ' . + $currencies->display_price( $this->contents[$cartItemKey]['final_price'], $this->contents[$cartItemKey]['tax'], $this->contents[$cartItemKey]['products_quantity'], $this->getField( 'currency' ), $this->getField( 'currency_value' ) ) . + ($this->contents[$cartItemKey]['onetime_charges'] !=0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->contents[$cartItemKey]['onetime_charges'], $this->contents[$cartItemKey]['tax'], 1) : ''); + foreach( array_keys( $this->contents[$cartItemKey]['attributes'] ) as $j ) { + $email_order .= "\n + " . zen_decode_specialchars($this->contents[$cartItemKey]['attributes'][$j]['option']) . ' ' . zen_decode_specialchars($this->contents[$cartItemKey]['attributes'][$j]['value']); } $email_order .= "\n\n"; } diff --git a/classes/CommerceProduct.php b/classes/CommerceProduct.php index b571011f..9781a879 100644 --- a/classes/CommerceProduct.php +++ b/classes/CommerceProduct.php @@ -1893,14 +1893,14 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $products_options_details = $vals['products_options_values_name']; } else { // don't show option value name on TEXT or filename - $products_options_details = '
'.$vals['products_options_values_name'].'
'; + $products_options_details = $vals['products_options_values_name']; } if ($this->mOptions[$optionsId]['products_options_images_style'] >= 3) { - $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight . '
' : ''); - $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? '
' . $products_options_display_weight . '
' : ''); + $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? $products_options_display_weight : ''); + $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? $products_options_display_weight : ''); } else { - $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? ' ' . $products_options_display_weight : ''); - $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? ' ' . $products_options_display_weight : ''); + $products_options_details .= $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? $products_options_display_weight : ''); + $products_options_details_noname = $vals['display_price'] . (!empty( $vals['products_attributes_wt'] ) ? $products_options_display_weight : ''); } } @@ -1927,7 +1927,11 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting } } // ignore products_options_images_style as this should be fully controllable via CSS - $tmp_radio .= zen_draw_radio_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . ']', $products_options_value_id, $selected_attribute, NULL, "$vals[products_options_values_name] $products_options_details_noname" . (!empty( $vals['attributes_image'] ) ? zen_image(DIR_WS_IMAGES . $vals['attributes_image'], '', '', '', '') : '') ); + $tmp_radio .= zen_draw_radio_field('id[' . $this->mOptions[$optionsId]['products_options_id'] . ']', $products_options_value_id, $selected_attribute, $this->mOptions[$optionsId]['products_options_html_attrib'], + "$vals[products_options_values_name]" + . (!empty( $products_options_details_noname ) ? " $products_options_details_noname" : '') + . (!empty( $vals['attributes_image'] ) ? zen_image(DIR_WS_IMAGES . $vals['attributes_image'], '', '', '', '') : '') + ); } @@ -1976,7 +1980,6 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { - $tmp_attributes_image .= ''; $tmp_attributes_image_row = 1; } @@ -1991,7 +1994,6 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { - $tmp_attributes_image .= ''; $tmp_attributes_image_row = 1; } @@ -2010,7 +2012,6 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { - $tmp_attributes_image .= ''; $tmp_attributes_image_row = 1; } @@ -2032,9 +2033,10 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting // =-=-=-=-=-=-=-=-=-=-= text if (($this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT)) { + $maxLength = !empty( $this->mOptions[$optionsId]['products_options_length'] ) ? 'maxlength="' . $this->mOptions[$optionsId]['products_options_length'] . '"' : ''; if( is_object( $pCart ) ) { $tmp_value = $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]; - $tmp_html = ' '; + $tmp_html .= ' '; $tmp_html .= $products_options_details; $tmp_word_cnt_string = ''; // calculate word charges @@ -2048,7 +2050,7 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting } if ($tmp_word_cnt != 0 and $tmp_word_price != 0) { $tmp_word_price = $currencies->display_price($tmp_word_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])); - $tmp_html = $tmp_html . '
' . TEXT_CHARGES_WORD . ' ' . $tmp_word_cnt . ' = ' . $tmp_word_price; + $tmp_html .= '
' . TEXT_CHARGES_WORD . ' ' . $tmp_word_cnt . ' = ' . $tmp_word_price . '
'; } // calculate letter charges $tmp_letters_cnt =0; @@ -2061,11 +2063,11 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting } if ($tmp_letters_cnt != 0 and $tmp_letters_price != 0) { $tmp_letters_price = $currencies->display_price($tmp_letters_price, zen_get_tax_rate($this->mInfo['products_tax_class_id'])); - $tmp_html = $tmp_html . '
' . TEXT_CHARGES_LETTERS . ' ' . $tmp_letters_cnt . ' = ' . $tmp_letters_price; + $tmp_html .= '
' . TEXT_CHARGES_LETTERS . ' ' . $tmp_letters_cnt . ' = ' . $tmp_letters_price . '
'; } } else { - $tmp_html = ''; + $tmp_html .= ''; $tmp_html .= $products_options_details; } } @@ -2077,10 +2079,10 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting if( is_object( $pCart ) && $this->mOptions[$optionsId]['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE) { $number_of_uploads++; - $tmp_html = '
' . + $tmp_html .= '
' . $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']] . - zen_draw_hidden_field(UPLOAD_PREFIX . $number_of_uploads, $this->mOptions[$optionsId]['products_options_id']) . - zen_draw_hidden_field(TEXT_PREFIX . UPLOAD_PREFIX . $number_of_uploads, $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]); + zen_draw_hidden_field( $number_of_uploads, $this->mOptions[$optionsId]['products_options_id']) . + zen_draw_hidden_field( $number_of_uploads, $pCart->contents[$this->mProductsId]['attributes_values'][$this->mOptions[$optionsId]['products_options_id']]); $tmp_html .= $products_options_details; } @@ -2091,7 +2093,6 @@ function getProductOptions( $pSelectedId = NULL, $pCart = NULL, &$productSetting $tmp_attributes_image_row++; if ($tmp_attributes_image_row > $this->mOptions[$optionsId]['products_options_images_per_row']) { - $tmp_attributes_image .= ''; $tmp_attributes_image_row = 1; } diff --git a/classes/CommerceProductManager.php b/classes/CommerceProductManager.php index 08b42687..1666175c 100644 --- a/classes/CommerceProductManager.php +++ b/classes/CommerceProductManager.php @@ -78,8 +78,7 @@ function verifyOption( &$pParamHash ) { $pParamHash['options_store'][$opt] = !empty( $pParamHash[$opt] ) || is_numeric( $pParamHash[$opt] ) ? $pParamHash[$opt] : NULL; } - $pParamHash['options_store']['products_options_length'] = is_numeric( $pParamHash['products_options_length'] ) ? $pParamHash['products_options_length'] : 32; - $pParamHash['options_store']['products_options_size'] = is_numeric( $pParamHash['products_options_size'] ) ? $pParamHash['products_options_size'] : 32; + $pParamHash['options_store']['products_options_length'] = is_numeric( $pParamHash['products_options_length'] ) ? $pParamHash['products_options_length'] : NULL; return( count( $this->mErrors ) == 0 && !empty( $pParamHash['options_store'] ) && count( $pParamHash['options_store'] ) ); } diff --git a/classes/CommerceShoppingCart.php b/classes/CommerceShoppingCart.php index 1411c01e..94e963d7 100644 --- a/classes/CommerceShoppingCart.php +++ b/classes/CommerceShoppingCart.php @@ -35,18 +35,15 @@ function load() { foreach( $products as $basketId=>$basketProduct ) { $this->contents[$basketProduct['products_key']] = $basketProduct; - $query = "SELECT `products_options_key` AS `hash_key`, cba.`products_options_id`, cba.`products_options_values_id`, `products_options_value_text` + $query = "SELECT cba.`products_options_id`||'='||cba.`products_options_values_id` AS `hash_key`, cba.`products_options_id`, cba.`products_options_values_id`, cba.`products_options_value_text` FROM " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " cba - INNER JOIN " . TABLE_PRODUCTS_OPTIONS . " cpo ON( cba.products_options_id=cpo.products_options_id ) INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " cpa ON ( cba.products_options_values_id=cpa.products_options_values_id ) + LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " cpo ON( cba.products_options_id=cpo.products_options_id ) WHERE cba.`customers_basket_id` = ? ORDER BY cpo.`products_options_sort_order`, cpa.`products_options_sort_order`"; if( $attributes = $this->mDb->getAssoc( $query, array( $basketId ) ) ) { - - foreach( $attributes as $productsOptionsKey=>$attribute ) - $this->contents[$basketProduct['products_key']]['attributes'][$productsOptionsKey] = $attribute['products_options_values_id']; - //CLR 020606 if text attribute, then set additional information - if ($attribute['products_options_values_id'] == PRODUCTS_OPTIONS_VALUES_TEXT_ID) { + foreach( $attributes as $productsOptionsKey=>$attribute ) { + $this->contents[$basketProduct['products_key']]['attributes'][$productsOptionsKey] = $attribute['products_options_values_id']; $this->contents[$basketProduct['products_key']]['attributes_values'][$productsOptionsKey] = $attribute['products_options_value_text']; } } @@ -80,75 +77,61 @@ function reset() { unset($this->cartID); } - function addToCart($pProductsKey, $pQty = '1', $attributes = '', $notify = true) { + function addToCart($pProductsId, $pQty = '1', $attributes = array(), $notify = true) { global $gBitUser, $gCommerceSystem; - $productsKey = zen_get_uprid($pProductsKey, $attributes); + $cartItemKey = $this->getUniqueCartItemKey( $pProductsId, $attributes ); + if ($notify == true) { - $_SESSION['new_products_id_in_cart'] = $productsKey; + $_SESSION['new_products_id_in_cart'] = $cartItemKey; } + $addQty = $this->get_quantity( $cartItemKey, $attributes ) + $pQty; // overflow protection - if( $pQty > MAX_CART_QUANTITY ) { - $pQty = MAX_CART_QUANTITY; + if( $addQty > MAX_CART_QUANTITY ) { + $addQty = MAX_CART_QUANTITY; } $this->StartTrans(); - if ($this->in_cart($productsKey)) { - $this->updateQuantity( $productsKey, $pQty ); - } elseif( $exists = $this->mDb->GetOne( "SELECT `products_id` FROM " . TABLE_PRODUCTS . " WHERE `products_id`=?", array( (int)zen_get_prid( $productsKey ) ) ) ) { + if ($this->in_cart($cartItemKey)) { + $this->updateQuantity( $cartItemKey, $addQty ); + } elseif( $exists = $this->mDb->GetOne( "SELECT `products_id` FROM " . TABLE_PRODUCTS . " WHERE `products_id`=?", array( (int)zen_get_prid( $cartItemKey ) ) ) ) { $selectColumn = $gBitUser->isRegistered() ? 'customers_id' : 'cookie' ; $selectValue = $gBitUser->isRegistered() ? $gBitUser->mUserId : session_id(); if( $gCommerceSystem->getConfig( 'QUANTITY_DECIMALS' ) ) { // This is some fractional product crap - hope it still works... switch (true) { - case (strstr($pQty, '.')): + case (strstr($addQty, '.')): // remove all trailing zeros after zero - $pQty = preg_replace('/[0]+$/','',$pQty); + $addQty = preg_replace('/[0]+$/','',$addQty); break; } } // insert into database $sql = "INSERT INTO " . TABLE_CUSTOMERS_BASKET . " (`$selectColumn`, `products_key`, `products_id`, `products_quantity`, `date_added`) values ( ?, ?, ?, ?, ? )"; - $this->mDb->query( $sql, array( $selectValue, $productsKey, zen_get_prid( $productsKey ), $pQty, date('Ymd') ) ); - $basketId = $this->mDb->GetOne( "SELECT MAX(`customers_basket_id`) FROM " . TABLE_CUSTOMERS_BASKET . " WHERE `products_key`=? AND `$selectColumn`=?", array( $productsKey, $selectValue ) ); + $this->mDb->query( $sql, array( $selectValue, $cartItemKey, zen_get_prid( $cartItemKey ), $addQty, date('Ymd') ) ); + $basketId = $this->mDb->GetOne( "SELECT MAX(`customers_basket_id`) FROM " . TABLE_CUSTOMERS_BASKET . " WHERE `products_key`=? AND `$selectColumn`=?", array( $cartItemKey, $selectValue ) ); if (is_array($attributes)) { reset($attributes); foreach( $attributes as $option=>$value ) { - // check if input was from text box. If so, store additional attribute information - // check if text input is blank, if so do not add to attribute lists - $attr_value = NULL; - $blank_value = FALSE; - if (strstr($option, TEXT_PREFIX)) { - if (trim($value) == NULL) { - $blank_value = TRUE; - } else { - $option = substr($option, strlen(TEXT_PREFIX)); - $attr_value = stripslashes($value); - $value = PRODUCTS_OPTIONS_VALUES_TEXT_ID; - } - } - - if (!$blank_value) { if (is_array($value) ) { reset($value); - while (list($opt, $val) = each($value)) { - $sql = "INSERT INTO " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " - (`customers_basket_id`, `products_options_id`, `products_options_key`, `products_options_values_id`) - VALUES ( ?, ?, ?, ? )"; - $this->mDb->query($sql, array( $basketId, (int)$option, (int)$option.'_chk'.$val, (int)$val ) ); + foreach( $value AS $optValId =>$optVal ) { + $sql = "INSERT INTO " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (`customers_basket_id`, `products_options_id`, `products_options_key`, `products_options_values_id`, `products_options_value_text`) VALUES ( ?, ?, ?, ?, ? )"; + $this->mDb->query($sql, array( $basketId, (int)$option, $option.'='.$optValId, (int)$optValId, ($optVal!=$optValId ? $optVal : NULL) ) ); } } else { // update db insert to include attribute value_text. This is needed for text attributes. $sql = "INSERT INTO " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (`customers_basket_id`, `products_options_id`, `products_options_key`, `products_options_values_id`, `products_options_value_text`) VALUES (?, ?, ?, ?, ?)"; - $this->mDb->query( $sql, array( $basketId, (int)$option, $option, (int)$value, $attr_value ) ); + $bindVars = array( $basketId, (int)$option, $option, (int)$value, (!is_numeric( $value ) ? $value : NULL) ); + $this->mDb->query( $sql, $bindVars ); } - } } } } + $this->CompleteTrans(); $this->cleanup(); @@ -158,6 +141,27 @@ function addToCart($pProductsKey, $pQty = '1', $attributes = '', $notify = true) $this->cartID = $this->generate_cart_id(); } + //// + // Return a unique product key based on attributes, used for ensuring uniqueness for shopping cart items + public static function getUniqueCartItemKey( $prid, $params ) { + if( (is_array($params)) && (!strstr($prid, ':')) ) { + $uprid = $prid; + while (list($option, $value) = each($params)) { + if (is_array($value)) { + while (list($opt, $val) = each($value)) { + $uprid .= '{' . $option . '}' . trim($opt).':'.trim($val); + } + } else { + $uprid .= '{' . $option . '}' . trim($value); + } + } + return $prid . ':' . md5($uprid); + } else { + return $prid; + } + } + + function verifyQuantity( $pProductsKey, $pQty ) { $pQty = (int)$pQty; @@ -193,27 +197,27 @@ function verifyQuantity( $pProductsKey, $pQty ) { function verifyCheckout() { global $gCommerceSystem; - foreach( $this->contents AS $productsKey => $productsHash ) { - $product = $this->getProductObject( $productsKey ); + foreach( $this->contents AS $cartItemKey => $productsHash ) { + $product = $this->getProductObject( $cartItemKey ); $check_quantity = $productsHash['products_quantity']; $check_quantity_min = $product->getField( 'products_quantity_order_min' ); // Check quantity min - if ($new_check_quantity = $this->in_cart_mixed( $productsKey ) ) { + if ($new_check_quantity = $this->in_cart_mixed( $cartItemKey ) ) { $check_quantity = $new_check_quantity; } $fix_once = 0; if ($check_quantity < $check_quantity_min) { $fix_once ++; - $this->mErrors['checkout'][$productsKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . $product->getQuantityMinUnitsDisplay() . ' '; + $this->mErrors['checkout'][$cartItemKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . $product->getQuantityMinUnitsDisplay() . ' '; } // Check Quantity Units if not already an error on Quantity Minimum if ($fix_once == 0) { $check_units = $product->getField( 'products_quantity_order_units' ); if ( fmod($check_quantity,$check_units) != 0 ) { - $this->mErrors['checkout'][$productsKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . $product->getQuantityMinUnitsDisplay() . ' '; + $this->mErrors['checkout'][$cartItemKey] = tra( 'Product: ' ) . $product->getTitle() . tra( ' ... Quantity Units errors - ' ) . tra( 'You ordered a total of: ' ) . $check_quantity . ' ' . $product->getQuantityMinUnitsDisplay() . ' '; } } @@ -221,9 +225,9 @@ function verifyCheckout() { if ( $gCommerceSystem->getConfig( 'STOCK_CHECK' ) && !$gCommerceSystem->getConfig( 'STOCK_ALLOW_CHECKOUT' ) ) { if( !$product->getField( 'products_quantity' ) && !$product->getField( 'products_virtual' ) ) { if( $gCommerceSystem->getConfig( 'STOCK_ALLOW_CHECKOUT' ) ) { - $this->mErrors['checkout'][$productsKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock.
Items not in stock will be placed on backorder.' ); + $this->mErrors['checkout'][$cartItemKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock.
Items not in stock will be placed on backorder.' ); } else { - $this->mErrors['checkout'][$productsKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock or there are not enough in stock to fill your order.
Please change the quantity of products marked with (' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '). Thank you' ); + $this->mErrors['checkout'][$cartItemKey] = tra( 'Products marked with ' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . ' are out of stock or there are not enough in stock to fill your order.
Please change the quantity of products marked with (' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '). Thank you' ); } } } @@ -276,8 +280,8 @@ function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); - while (list($productsKey, ) = each($this->contents)) { - $total_items += $this->get_quantity($productsKey); + while (list($cartItemKey, ) = each($this->contents)) { + $total_items += $this->get_quantity($cartItemKey); } } @@ -309,8 +313,8 @@ function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); - while (list($productsKey, ) = each($this->contents)) { - $product_id_list .= ', ' . zen_db_input($productsKey); + while (list($cartItemKey, ) = each($this->contents)) { + $product_id_list .= ', ' . zen_db_input($cartItemKey); } } @@ -335,16 +339,16 @@ function calculate( $pForceRecalculate=FALSE ) { } reset($this->contents); - foreach( array_keys( $this->contents ) as $productsKey ) { - $qty = $this->contents[$productsKey]['products_quantity']; - // $productsKey will be unique joined string of products_id:hash for cart, eg: 17054:be19531ba04f4dc3fd33bca49a16dca8 - $prid = zen_get_prid( $productsKey ); + foreach( array_keys( $this->contents ) as $cartItemKey ) { + $qty = $this->contents[$cartItemKey]['products_quantity']; + // $cartItemKey will be unique joined string of products_id:hash for cart, eg: 17054:be19531ba04f4dc3fd33bca49a16dca8 + $prid = zen_get_prid( $cartItemKey ); // products price $product = $this->getProductObject( $prid ); // sometimes 0 hash things can get stuck in cart. if( $product && $product->isValid() ) { - $productAttributes = !empty( $this->contents[$productsKey]['attributes'] ) ? $this->contents[$productsKey]['attributes'] : array(); + $productAttributes = !empty( $this->contents[$cartItemKey]['attributes'] ) ? $this->contents[$cartItemKey]['attributes'] : array(); $products_tax = zen_get_tax_rate($product->getField('products_tax_class_id')); $purchasePrice = $product->getPurchasePrice( $qty, $productAttributes ); $onetimeCharges = $product->getOneTimeCharges( $qty, $productAttributes ); @@ -353,7 +357,7 @@ function calculate( $pForceRecalculate=FALSE ) { $productsTotal = zen_add_tax( (($purchasePrice * $qty) + $onetimeCharges), $products_tax); // shipping adjustments - if (($product->getField('product_is_always_free_ship') == 1) || $product->isVirtual( $this->contents[$productsKey] ) || (preg_match('/^GIFT/', addslashes($product->getField('products_model'))))) { + if (($product->getField('product_is_always_free_ship') == 1) || $product->isVirtual( $this->contents[$cartItemKey] ) || (preg_match('/^GIFT/', addslashes($product->getField('products_model'))))) { $this->free_shipping_item += $qty; $this->free_shipping_price += $productsTotal; $this->free_shipping_weight += $productWeight; @@ -377,9 +381,9 @@ public function getProductHash( $pProductsKey ) { if( $product && $product->isValid() ) { $prid = $product->mProductsId; - $attr = !empty( $this->contents[$pProductsKey]['attributes'] ) ? $this->contents[$pProductsKey]['attributes'] : array(); - - $productHash =$product->mInfo; + $productHash = $product->mInfo; + $productHash['attributes'] = $this->getParameter( $this->contents[$pProductsKey], 'attributes' ); + $productHash['attributes_values'] = $this->getParameter( $this->contents[$pProductsKey], 'attributes_values' ); // this is the stock quantity coming out of mInfo unset( $productHash['products_quantity'] ); $productHash['id'] = $pProductsKey; @@ -391,18 +395,16 @@ public function getProductHash( $pProductsKey ) { $productHash['image_url'] = $product->getImageUrl(); $productHash['products_quantity'] = (!empty( $this->contents[$pProductsKey]['products_quantity'] ) ? $this->contents[$pProductsKey]['products_quantity'] : NULL); $productHash['commission'] = $product->getCommissionUserCharges(); - $productHash['weight'] = $product->getWeight( $productHash['products_quantity'], $attr ); - $productHash['price'] = $product->getPurchasePrice( $productHash['products_quantity'], $attr ); + $productHash['weight'] = $product->getWeight( $productHash['products_quantity'], $productHash['attributes'] ); + $productHash['price'] = $product->getPurchasePrice( $productHash['products_quantity'], $productHash['attributes'] ); $productHash['tax_rate'] = zen_get_tax_rate( $product->getField( 'products_tax_class_id' ) ); $productHash['final_price'] = $productHash['price']; $productHash['final_price_display'] = $currencies->display_price( $productHash['final_price'] , $productHash['tax_rate'], $productHash['products_quantity'] ); - $productHash['onetime_charges'] = $product->getOneTimeCharges( $productHash['products_quantity'], $attr ); + $productHash['onetime_charges'] = $product->getOneTimeCharges( $productHash['products_quantity'], $productHash['attributes'] ); $productHash['onetime_charges_display'] = $currencies->display_price($productHash['onetime_charges'], $productHash['tax_rate'], 1); $productHash['tax_class_id'] = $product->getField('products_tax_class_id'); $productHash['tax'] = $product->getField('tax_rate'); $productHash['tax_description'] = $product->getField('tax_description'); - $productHash['attributes'] = $attr; - $productHash['attributes_values'] = (isset( $productHash['attributes_values'] ) ? $productHash['attributes_values'] : ''); } return $productHash; @@ -436,14 +438,14 @@ function get_content_type($gv_only = 'false') { if ( $this->count_contents() > 0 ) { reset($this->contents); - foreach( array_keys( $this->contents ) as $productsKey ) { - if( $product = $this->getProductObject( $productsKey ) ) { + foreach( array_keys( $this->contents ) as $cartItemKey ) { + if( $product = $this->getProductObject( $cartItemKey ) ) { if( preg_match( '/^GIFT/', addslashes( $product->getField( 'products_model' ) ) ) ) { - $gift_voucher += $product->getPurchasePrice( $this->contents[$productsKey]['products_quantity'], $this->contents[$productsKey]['attributes'] ); + $gift_voucher += $product->getPurchasePrice( $this->contents[$cartItemKey]['products_quantity'], $this->contents[$cartItemKey]['attributes'] ); } - if (isset($this->contents[$productsKey]['attributes'])) { - reset($this->contents[$productsKey]['attributes']); - while (list(, $value) = each($this->contents[$productsKey]['attributes'])) { + if (isset($this->contents[$cartItemKey]['attributes'])) { + reset($this->contents[$cartItemKey]['attributes']); + while (list(, $value) = each($this->contents[$cartItemKey]['attributes'])) { $virtual_check_query = "SELECT COUNT(*) as `total` FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON(pa.`products_options_values_id` = pad.`products_options_values_id`) @@ -628,12 +630,12 @@ function in_cart_check($check_what, $check_value='1') { $in_cart_check_qty=0; reset($this->contents); - while (list($productsKey, ) = each($this->contents)) { - $testing_id = zen_get_prid($productsKey); + while (list($cartItemKey, ) = each($this->contents)) { + $testing_id = zen_get_prid($cartItemKey); // check if field it true $product_check = $this->mDb->getOne("select " . $check_what . " as `check_it` from " . TABLE_PRODUCTS . " where `products_id` = ?" , array( $testing_id ) ); if( $product_check == $check_value ) { - $in_cart_check_qty += $this->contents[$productsKey]['products_quantity']; + $in_cart_check_qty += $this->contents[$cartItemKey]['products_quantity']; } } return $in_cart_check_qty; diff --git a/includes/application_top.php b/includes/application_top.php index b39c7f86..784f4cab 100644 --- a/includes/application_top.php +++ b/includes/application_top.php @@ -212,7 +212,7 @@ function clean_input( &$pArray ) { $check = zen_get_attributes_valid($_POST['products_id'], $key, $value); if ($check == false) { // zen_get_products_name($_POST['products_id']) . - $the_list .= TEXT_ERROR_OPTION_FOR . '' . zen_options_name($key) . '' . TEXT_INVALID_SELECTION_LABELED . '' . (zen_values_name($value) == 'TEXT' ? TEXT_INVALID_USER_INPUT : zen_values_name($value)) . '' . '
'; + $the_list .= '
' . TEXT_ERROR_OPTION_FOR . TEXT_INVALID_SELECTION_LABELED . ' : ' . $key .' = '. $value . '
'; } } } @@ -223,7 +223,7 @@ function clean_input( &$pArray ) { // process normally // iii 030813 added: File uploading: save uploaded files with unique file names - $real_ids = !empty( $_REQUEST['id'] ) ? $_REQUEST['id'] : 0; + $cartAttributes = !empty( $_REQUEST['id'] ) ? $_REQUEST['id'] : 0; if( !empty( $_REQUEST['number_of_uploads'] ) ) { require_once(DIR_FS_CLASSES . 'upload.php'); for ($i = 1, $n = $_REQUEST['number_of_uploads']; $i <= $n; $i++) { @@ -238,7 +238,7 @@ function clean_input( &$pArray ) { $gBitDb->Execute("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . zen_session_id() . "', '" . zen_db_input($products_options_file->filename) . "')"); } $insert_id = zen_db_insert_id( TABLE_FILES_UPLOADED, 'files_uploaded_id' ); - $real_ids[TEXT_PREFIX . $_REQUEST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename; + $cartAttributes[TEXT_PREFIX . $_REQUEST[UPLOAD_PREFIX . $i]] = $insert_id . ". " . $products_options_file->filename; $products_options_file->set_filename("$insert_id" . $products_image_extention); if (!($products_options_file->save())) { break 2; @@ -247,12 +247,11 @@ function clean_input( &$pArray ) { break 2; } } else { // No file uploaded -- use previous value - $real_ids[TEXT_PREFIX . $_REQUEST[UPLOAD_PREFIX . $i]] = $_REQUEST[TEXT_PREFIX . UPLOAD_PREFIX . $i]; + $cartAttributes[TEXT_PREFIX . $_REQUEST[UPLOAD_PREFIX . $i]] = $_REQUEST[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } } } - - $gBitCustomer->mCart->addToCart( $_POST['products_id'], ($gBitCustomer->mCart->get_quantity(zen_get_uprid($_POST['products_id'], $real_ids)) + $_POST['cart_quantity'] ), $real_ids ); + $gBitCustomer->mCart->addToCart( $_POST['products_id'], $_POST['cart_quantity'], $cartAttributes ); } } @@ -269,7 +268,7 @@ function clean_input( &$pArray ) { if (zen_has_product_attributes($_REQUEST['products_id'])) { zen_redirect( $gBitProduct->getDisplayUrl() ); } else { - $gBitCustomer->mCart->addToCart($_REQUEST['products_id'], ($gBitCustomer->mCart->get_quantity( $_REQUEST['products_id'] ) + $gBitProduct->getBuyNowQuantity() ) ); + $gBitCustomer->mCart->addToCart($_REQUEST['products_id'], $gBitProduct->getBuyNowQuantity() ); } } zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters))); @@ -278,7 +277,7 @@ function clean_input( &$pArray ) { case 'multiple_products_add_product': while ( list( $key, $qty ) = each($_REQUEST['products_id']) ) { if( !zen_has_product_attributes( $_REQUEST['products_id'] ) ) { - $gBitCustomer->mCart->addToCart($prodId, ($gBitCustomer->mCart->get_quantity($prodId) + $qty) ); + $gBitCustomer->mCart->addToCart($prodId, $qty ); } } zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters))); @@ -316,17 +315,6 @@ function clean_input( &$pArray ) { zen_redirect(FILENAME_LOGIN); } break; - case 'cust_order' : - if ($_SESSION['customer_id'] && isset($_REQUEST['pid'])) { - if (zen_has_product_attributes($_REQUEST['pid'])) { - zen_redirect(zen_href_link(zen_get_info_page($_REQUEST['pid']), 'products_id=' . $_REQUEST['pid'])); - } else { - $gBitDb->Execute("delete FROM " . TABLE_WISHLIST . " WHERE `products_id` = '" . $_REQUEST['pid'] . "' and `customers_id` = '" . $_SESSION['customer_id'] . "'"); - $gBitCustomer->mCart->addToCart($_REQUEST['pid'], $gBitCustomer->mCart->get_quantity($_REQUEST['pid'])+1); - } - } - zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters))); - break; case 'add_wishlist' : // Add product to the wishlist diff --git a/includes/functions/functions_general.php b/includes/functions/functions_general.php index 7c57075b..14f0d7e1 100644 --- a/includes/functions/functions_general.php +++ b/includes/functions/functions_general.php @@ -420,44 +420,6 @@ function zen_create_sort_heading($sortby, $colnum, $heading) { } -//// -// Return a product ID with attributes -/* - function zen_get_uprid_OLD($prid, $params) { - $uprid = $prid; - if ( (is_array($params)) && (!strstr($prid, '{')) ) { - while (list($option, $value) = each($params)) { - $uprid = $uprid . '{' . $option . '}' . $value; - } - } - - return $uprid; - } -*/ - - -//// -// Return a product ID with attributes -function zen_get_uprid($prid, $params) { -//print_r($params); - if( (is_array($params)) && (!strstr($prid, ':')) ) { - $uprid = $prid; - while (list($option, $value) = each($params)) { - if (is_array($value)) { - while (list($opt, $val) = each($value)) { - $uprid .= '{' . $option . '}' . trim($opt); - } - } else { - $uprid .= '{' . $option . '}' . trim($value); - } - } - return $prid . ':' . md5($uprid); - } else { - return $prid; - } -} - - //// //! Send email (text/html) using MIME // This is the old central mail function. The SMTP Server should be configured correctly in php.ini diff --git a/includes/functions/functions_lookups.php b/includes/functions/functions_lookups.php index 922f6e51..207450ef 100644 --- a/includes/functions/functions_lookups.php +++ b/includes/functions/functions_lookups.php @@ -465,19 +465,6 @@ function zen_get_attributes_valid($product_id, $option, $value) { return $check_valid; } - function zen_options_name($options_id) { - global $gBitDb; - - $options_id = str_replace('txt_','',$options_id); - - $options_values = $gBitDb->Execute("select `products_options_name` - from " . TABLE_PRODUCTS_OPTIONS . " - where `products_options_id` = '" . (int)$options_id . "' - and `language_id` = '" . (int)$_SESSION['languages_id'] . "'"); - - return $options_values->fields['products_options_name']; - } - //// // configuration key value lookup function zen_get_configuration_key_value($lookup) { diff --git a/modules/mod_order_history.php b/modules/mod_order_history.php deleted file mode 100644 index e172a017..00000000 --- a/modules/mod_order_history.php +++ /dev/null @@ -1,68 +0,0 @@ -isRegistered() ) { - // retreive the last x products purchased - $orders_history_query = "select distinct op.`products_id`, o.date_purchased - from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_PRODUCTS . " p - where o.`customers_id` = ? - and o.`orders_id` = op.`orders_id` - and op.`products_id` = p.`products_id` - and p.`products_status` = '1' - order by o.date_purchased desc"; - - $orders_history = $gBitDb->query( $orders_history_query, $gBitUser->mUserId,MAX_DISPLAY_PRODUCTS_IN_ORDER_HISTORY_BOX ); - - if ($orders_history->RecordCount() > 0) { - $product_ids = ''; - while (!$orders_history->EOF) { - $product_ids .= (int)$orders_history->fields['products_id'] . ','; - $orders_history->MoveNext(); - } - $product_ids = substr($product_ids, 0, -1); - $rows=0; - $customer_orders_string = ''; - $products_history_query = "select `products_id`, `products_name` - from " . TABLE_PRODUCTS_DESCRIPTION . " - where `products_id` in (" . $product_ids . ") - and `language_id` = '" . (int)$_SESSION['languages_id'] . "' - order by `products_name`"; - - $products_history = $gBitDb->Execute($products_history_query); - - while (!$products_history->EOF) { - $rows++; - $customer_orders[$rows] = $products_history->fields; - $customer_orders[$rows]['display_url'] = CommerceProduct::getDisplayUrlFromId( $products_history->fields['products_id'] ); - $products_history->MoveNext(); - } - - $_template->tpl_vars['sideboxCustomerOrders'] = new Smarty_variable( $customer_orders ); - - } - if( empty( $moduleTitle ) ) { - $_template->tpl_vars['moduleTitle'] = new Smarty_variable( 'Order History' ); - } -} -?> diff --git a/modules/mod_order_history.tpl b/modules/mod_order_history.tpl deleted file mode 100644 index a9e55717..00000000 --- a/modules/mod_order_history.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{strip} -{if $sideboxCustomerOrders} - {bitmodule title=$moduleTitle name="bc_orderhistory"} - - {/bitmodule} -{/if} -{/strip} diff --git a/pages/checkout_confirmation/checkout_confirmation.php b/pages/checkout_confirmation/checkout_confirmation.php index 881410c5..b9608217 100644 --- a/pages/checkout_confirmation/checkout_confirmation.php +++ b/pages/checkout_confirmation/checkout_confirmation.php @@ -58,8 +58,10 @@ } // load the selected shipping module -require( BITCOMMERCE_PKG_PATH.'classes/CommerceShipping.php'); -$shipping_modules = new CommerceShipping($_SESSION['shipping']); +if( !empty( $_SESSION['shipping'] ) ) { + require( BITCOMMERCE_PKG_PATH.'classes/CommerceShipping.php'); + $shipping_modules = new CommerceShipping($_SESSION['shipping']); +} // update customers_referral with $_SESSION['gv_id'] diff --git a/pages/checkout_payment/checkout_payment.php b/pages/checkout_payment/checkout_payment.php index d232c1d1..8049fd7b 100644 --- a/pages/checkout_payment/checkout_payment.php +++ b/pages/checkout_payment/checkout_payment.php @@ -81,10 +81,6 @@ echo $paymentManager->javascript_validation(); $gBitSmarty->assign( 'paymentSelection', $paymentManager->selection() ); - // Load the selected shipping module(needed to calculate tax correctly) - require( BITCOMMERCE_PKG_PATH.'classes/CommerceShipping.php'); - $shipping_modules = new CommerceShipping( $_SESSION['shipping'] ); - require_once(DIR_FS_MODULES . 'require_languages.php'); if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) { diff --git a/pages/document_general_info/main_template_vars_attributes.php b/pages/document_general_info/main_template_vars_attributes.php index 72e1fd4d..5401e6fa 100644 --- a/pages/document_general_info/main_template_vars_attributes.php +++ b/pages/document_general_info/main_template_vars_attributes.php @@ -39,10 +39,7 @@ $options_order_by= ' order by popt.products_options_name'; } - $sql = "select distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, - popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_size`, - popt.`products_options_images_per_row`, - popt.`products_options_images_style` + $sql = "SELECT distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_images_per_row`, popt.`products_options_images_style` FROM " . TABLE_PRODUCTS_OPTIONS . " popt INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON (pa.`products_options_id` = popt.`products_options_id`) INNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON (pa.`products_options_values_id`=pom.`products_options_values_id`) diff --git a/pages/document_product_info/main_template_vars_attributes.php b/pages/document_product_info/main_template_vars_attributes.php index 0dc81dc3..278ca086 100644 --- a/pages/document_product_info/main_template_vars_attributes.php +++ b/pages/document_product_info/main_template_vars_attributes.php @@ -39,10 +39,7 @@ $options_order_by= ' order by popt.products_options_name'; } - $sql = "select distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, - popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_size`, - popt.`products_options_images_per_row`, - popt.`products_options_images_style` + $sql = "SELECT distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_images_per_row`, popt.`products_options_images_style` FROM " . TABLE_PRODUCTS_OPTIONS . " popt INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON (pa.`products_options_id` = popt.`products_options_id`) INNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON (pa.`products_options_values_id`=pom.`products_options_values_id`) @@ -413,7 +410,7 @@ while(list($key,$value) = each($_POST['id'])) { if ((str_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'])) { // if ((str_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'] and $value == $products_options->fields['products_options_values_id'])) { - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; break; } @@ -421,7 +418,7 @@ } else { $tmp_value = $gBitCustomer->mCart->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']]; - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; $tmp_word_cnt_string = ''; // calculate word charges diff --git a/pages/popup_attributes_qty_prices/popup_attributes_qty_prices.php b/pages/popup_attributes_qty_prices/popup_attributes_qty_prices.php index 8a808ac5..be06bab3 100644 --- a/pages/popup_attributes_qty_prices/popup_attributes_qty_prices.php +++ b/pages/popup_attributes_qty_prices/popup_attributes_qty_prices.php @@ -44,8 +44,7 @@ $options_order_by= ' order by popt.products_options_name'; } - $sql = "select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order, - popt.products_options_type, popt.products_options_length, popt.products_options_comment, popt.products_options_size + $sql = "select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.`products_id`='" . (int)$_GET['products_id'] . "' and patrib.options_id = popt.products_options_id @@ -141,7 +140,7 @@ } $sql = "select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order, - popt.products_options_type, popt.products_options_length, popt.products_options_comment, popt.products_options_size + popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.`products_id`='" . (int)$_GET['products_id'] . "' and patrib.options_id = popt.products_options_id diff --git a/pages/product_free_shipping_info/main_template_vars_attributes.php b/pages/product_free_shipping_info/main_template_vars_attributes.php index f7fa4071..06998276 100644 --- a/pages/product_free_shipping_info/main_template_vars_attributes.php +++ b/pages/product_free_shipping_info/main_template_vars_attributes.php @@ -39,10 +39,7 @@ $options_order_by= ' order by popt.products_options_name'; } - $sql = "select distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, - popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_size`, - popt.`products_options_images_per_row`, - popt.`products_options_images_style` + $sql = "SELECT distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_images_per_row`, popt.`products_options_images_style` FROM " . TABLE_PRODUCTS_OPTIONS . " popt INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON (pa.`products_options_id` = popt.`products_options_id`) INNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON (pa.`products_options_values_id`=pom.`products_options_values_id`) @@ -413,7 +410,7 @@ while(list($key,$value) = each($_POST['id'])) { if ((str_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'])) { // if ((str_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'] and $value == $products_options->fields['products_options_values_id'])) { - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; break; } @@ -421,7 +418,7 @@ } else { $tmp_value = $gBitCustomer->mCart->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']]; - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; $tmp_word_cnt_string = ''; // calculate word charges diff --git a/pages/product_music_info/main_template_vars_attributes.php b/pages/product_music_info/main_template_vars_attributes.php index 5c72f846..f3793b8f 100644 --- a/pages/product_music_info/main_template_vars_attributes.php +++ b/pages/product_music_info/main_template_vars_attributes.php @@ -39,10 +39,7 @@ $options_order_by= ' order by popt.products_options_name'; } - $sql = "select distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, - popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_size`, - popt.`products_options_images_per_row`, - popt.`products_options_images_style` + $sql = "SELECT distinct popt.`products_options_id`, popt.`products_options_name`, popt.`products_options_sort_order`, popt.`products_options_type`, popt.`products_options_length`, popt.`products_options_comment`, popt.`products_options_images_per_row`, popt.`products_options_images_style` FROM " . TABLE_PRODUCTS_OPTIONS . " popt INNER JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa ON (pa.`products_options_id` = popt.`products_options_id`) INNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON (pa.`products_options_values_id`=pom.`products_options_values_id`) @@ -413,7 +410,7 @@ while(list($key,$value) = each($_POST['id'])) { if ((str_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'])) { // if ((str_replace('txt_', '', $key) == $products_options_names->fields['products_options_id'] and $value == $products_options->fields['products_options_values_id'])) { - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; break; } @@ -421,7 +418,7 @@ } else { $tmp_value = $gBitCustomer->mCart->contents[$_GET['products_id']]['attributes_values'][$products_options_names->fields['products_options_id']]; - $tmp_html = ' '; + $tmp_html = ' '; $tmp_html .= $products_options_details; $tmp_word_cnt_string = ''; // calculate word charges diff --git a/templates/admin_products_options_edit_inc.tpl b/templates/admin_products_options_edit_inc.tpl index f9d9c54b..0104cecf 100644 --- a/templates/admin_products_options_edit_inc.tpl +++ b/templates/admin_products_options_edit_inc.tpl @@ -47,13 +47,7 @@ {/forminput}
- {formlabel label="Display Size"} - {forminput} - - {/forminput} -
-
- {formlabel label="Maximum Length"} + {formlabel label="Maximum Text Length"} {forminput} {/forminput} diff --git a/templates/page_checkout_confirmation.tpl b/templates/page_checkout_confirmation.tpl index acbe530d..5dbfd1e9 100644 --- a/templates/page_checkout_confirmation.tpl +++ b/templates/page_checkout_confirmation.tpl @@ -11,39 +11,41 @@ {assign var=colspan value=2} {/if} {foreach from=$order->contents item=orderItem key=opid} -
-
+
+
+ {if $orderItem.image_url} +
{$orderItem.name|escape}
-
+ {/if} +
{$orderItem.name} - {if !empty( $orderItem.attributes )} -
-
    - {foreach $orderItem.attributes item=orderItemAttribute} -
  • {$orderItemAttribute.option|escape} : {$orderItemAttribute.value}
  • - {/foreach} -
-
- {/if} -
+
+
+ {tr}Qty.{/tr} {$orderItem.products_quantity} +
+
{if sizeof($order->info.tax_groups) > 1} -
{if !empty( $orderItem.tax )} {$orderItem.tax|zen_display_tax_value}% {/if} -
{/if} -
- Qty. {$orderItem.products_quantity} -
-
{$gCommerceCurrencies->display_price($orderItem.final_price, $orderItem.tax, $orderItem.products_quantity)} {if $orderItem.onetime_charges != 0}
{$gCommerceCurrencies->display_price($orderItem.onetime_charges, $orderItem.tax, 1)}
{/if}
+ {if !empty( $orderItem.attributes )} +
+
    + {foreach $orderItem.attributes item=orderItemAttribute} +
  • {$orderItemAttribute.option|escape} : {$orderItemAttribute.value}
  • + {/foreach} +
+
+ {/if}
+
{/foreach} {if $order->content_type!='virtual' && $order->info.shipping_method}

{tr}Shipping Method{/tr}: {$order->info.shipping_method}  {tr}Change{/tr}

diff --git a/templates/page_shopping_cart.tpl b/templates/page_shopping_cart.tpl index 7a846170..f5c753bf 100644 --- a/templates/page_shopping_cart.tpl +++ b/templates/page_shopping_cart.tpl @@ -31,7 +31,10 @@
    {foreach from=$basket.attributes key=optionKey item=valueId} {assign var=option value=$product->getOptionValue('',$valueId)} -
  • {$option.products_options_values_name}
  • +
  • + {$option.products_options_values_name} + {if $basket.attributes_values.$optionKey}
    {$basket.attributes_values.$optionKey}
    {/if} +
  • {/foreach}
{/if}