Page MenuHomeIn-Portal Phabricator

in-commerce
No OneTemporary

File Metadata

Created
Sat, Sep 20, 6:18 PM

in-commerce

Index: branches/5.2.x/constants.php
===================================================================
--- branches/5.2.x/constants.php (revision 15019)
+++ branches/5.2.x/constants.php (revision 15020)
@@ -1,129 +1,137 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
// order statuses
define('ORDER_STATUS_INCOMPLETE', 0);
define('ORDER_STATUS_PENDING', 1);
define('ORDER_STATUS_BACKORDERS', 2);
define('ORDER_STATUS_TOSHIP', 3);
define('ORDER_STATUS_PROCESSED', 4);
define('ORDER_STATUS_DENIED', 5);
define('ORDER_STATUS_ARCHIVED', 6);
/**
* ID of order, that 100% not in database
*
*/
define('FAKE_ORDER_ID', -1);
define('PRODUCT_TYPE_TANGIBLE', 1);
define('PRODUCT_TYPE_SUBSCRIPTION', 2);
define('PRODUCT_TYPE_SERVICE', 3);
define('PRODUCT_TYPE_DOWNLOADABLE', 4);
define('PRODUCT_TYPE_PACKAGE', 5);
// payment gateway processing statuses
define('SHIPPING_CONTROL_DIRECT', 3);
define('SHIPPING_CONTROL_PREAUTH', 4);
// gift certificate statuses
define('gcENABLED', 1);
define('gcUSED', 2);
define('gcDISABLED', 0);
define('USPS_LABEL_FOLDER', WRITEABLE . '/user_files/labels/');
define('ORDER_SHIP_ALL_TOGETHER', 0);
define('ORDER_SHIP_BACKORDERS_SEPARATELY', 1);
define('ORDER_SHIP_BACKORDERS_UPON_AVAILABLE', 2);
define('ORDER_GROUP_SHIPPMENTS_AUTO', 0);
define('ORDER_GROUP_SHIPPMENTS_MANUAL', 1);
define('PRODUCT_SHIPPING_MODE_ANY_AND_SELECTED', 0);
define('PRODUCT_SHIPPING_MODE_SELECTED_ONLY', 1);
class OrderCheckoutError {
const STATE_CHANGED = 10;
const CHANGED_AFTER_LOGIN = 11;
const QTY_UNAVAILABLE = 20; // orditems:Quantity (users tries to order more, then in stock)
const QTY_OUT_OF_STOCK = 21; // orditems:Quantity (product was sold out, after it was added to cart, but before checkout)
const QTY_CHANGED_TO_MINIMAL = 22; // orditems:Quantity (qty change to minimal available by price brackets)
const COUPON_APPLIED = 30; // orditems:ItemData, general
const COUPON_REMOVED = 31; // orditems:ItemData, general
const COUPON_REMOVED_AUTOMATICALLY = 32; // when discount is more efficient, then coupon being applied
const COUPON_CODE_INVALID = 33; // general
const COUPON_CODE_EXPIRED = 34; // general
const GC_APPLIED = 40; // general
const GC_REMOVED = 41; // general
const GC_REMOVED_AUTOMATICALLY = 42; // general
const GC_CODE_INVALID = 43; // general
const GC_CODE_EXPIRED = 44; // general
// new, to integrate
const DISCOUNT_APPLIED = 50; // orditems:ItemData, general
const DISCOUNT_REMOVED = 51; // orditems:ItemData, general
const FIELD_UPDATE_SUCCESS = 60; // when order item field is changed + not discount/coupon related
const FIELD_UPDATE_ERROR = 61; // when order item field can't be changed + not discount/coupon related
}
class OrderCheckoutErrorType {
const PRODUCT = 1;
const COUPON = 2;
const GIFT_CERTIFICATE = 3;
const DISCOUNT = 4;
}
class ProductInventory {
const DISABLED = 0;
const BY_PRODUCT = 1;
const BY_OPTIONS = 2;
}
class ProductBackorder {
const AUTO = 2;
const ALWAYS = 1;
const NEVER = 0;
}
+ class OptionType {
+ const DROPDOWN = 1;
+ const TEXT = 5;
+ const TEXTAREA = 4;
+ const RADIO = 3;
+ const CHECKBOX = 6;
+ }
+
class OptionCombinationPriceType {
const EQUALS = 1;
const FLAT = 2;
const PECENT = 3;
}
class DiscountType {
const FLAT = 1;
const PERCENT = 2;
}
class DiscountItemType {
const PRODUCT = 1;
const CATEGORY = 2;
const WHOLE_ORDER = 0;
}
class CouponType {
const FLAT = 1;
const PERCENT = 2;
}
class CouponItemType {
const PRODUCT = 1;
const CATEGORY = 2;
const WHOLE_ORDER = 0;
}
Index: branches/5.2.x/units/product_options/product_options_tag_processor.php
===================================================================
--- branches/5.2.x/units/product_options/product_options_tag_processor.php (revision 15019)
+++ branches/5.2.x/units/product_options/product_options_tag_processor.php (revision 15020)
@@ -1,158 +1,175 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ProductOptionsTagProcessor extends kDBTagProcessor {
function ShowOptions($params)
{
- $object =& $this->Application->recallObject($this->getPrefixSpecial());
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
$opt_helper =& $this->Application->recallObject('kProductOptionsHelper');
+ /* @var $opt_helper kProductOptionsHelper */
$parsed = $opt_helper->ExplodeOptionValues($object->GetFieldValues());
if ( !$parsed ) {
return '';
}
$values = $parsed['Values'];
$conv_prices = $parsed['Prices'];
$conv_price_types = $parsed['PriceTypes'];
$options =& $this->GetOptions();
$mode = $this->SelectParam($params, 'mode');
$combination_prefix = $this->SelectParam($params, 'combination_prefix');
$combination_field = $this->SelectParam($params, 'combination_field');
- if ($mode == 'selected') {
+
+ if ( $mode == 'selected' ) {
$comb =& $this->Application->recallObject($combination_prefix);
+ /* @var $comb kDBItem */
+
$options = unserialize($comb->GetDBField($combination_field));
}
$block_params['name'] = $params['render_as'];
$block_params['selected'] = '';
$block_params['pass_params'] = 1;
$lang =& $this->Application->recallObject('lang.current');
+ /* @var $lang LanguagesItem */
$o = '';
$first_selected = false;
+
foreach ($values as $option) {
// list($val, $label) = explode('|', $option);
$val = $option;
- if (getArrayValue($params, 'js')) {
+
+ if ( getArrayValue($params, 'js') ) {
$block_params['id'] = addslashes($val);
$block_params['value'] = htmlspecialchars($val);
}
else {
$block_params['id'] = htmlspecialchars($val);
$block_params['value'] = htmlspecialchars($val);
}
- if ($conv_prices[$val]) {
- if ($conv_price_types[$val] == '$' && !getArrayValue($params, 'js') && !getArrayValue($params, 'no_currency')) {
+
+ if ( $conv_prices[$val] ) {
+ if ( $conv_price_types[$val] == '$' && !getArrayValue($params, 'js') && !getArrayValue($params, 'no_currency') ) {
$iso = $this->GetISO($params['currency']);
$value = sprintf("%.2f", $this->ConvertCurrency($conv_prices[$val], $iso));
$value = $this->AddCurrencySymbol($lang->formatNumber($value, 2), $iso, true); // true to force sign
$block_params['price'] = $value;
$block_params['price_type'] = '';
$block_params['sign'] = ''; //sign is included in the formatted value
}
else {
- $block_params['price'] = isset($params['js']) ? $conv_prices[$val] : $lang->formatNumber($conv_prices[$val],2);
+ $block_params['price'] = isset($params['js']) ? $conv_prices[$val] : $lang->formatNumber($conv_prices[$val], 2);
$block_params['price_type'] = $conv_price_types[$val];
$block_params['sign'] = $conv_prices[$val] >= 0 ? '+' : '-';
}
}
else {
$block_params['price'] = '';
$block_params['price_type'] = '';
$block_params['sign'] = '';
}
/*if ($mode == 'selected') {
- $selected = $combination[$object->GetId()] == $val;
+ $selected = $combination[$object->GetID()] == $val;
}
else*/
$selected = false;
- if (!$options && isset($params['preselect_first']) && $params['preselect_first'] && !$first_selected) {
+
+ if ( !$options && isset($params['preselect_first']) && $params['preselect_first'] && !$first_selected ) {
$selected = true;
$first_selected = true;
}
- if (is_array($options)) {
- if ($object->GetDBField('OptionType') == 6) { // checkboxeS
- $selected = in_array(htmlspecialchars($val), $options[$object->GetId()]);
+
+ if ( is_array($options) ) {
+ $option_value = array_key_exists($object->GetID(), $options) ? $options[$object->GetID()] : '';
+
+ if ( $object->GetDBField('OptionType') == OptionType::CHECKBOX ) {
+ $selected = is_array($option_value) && in_array(htmlspecialchars($val), $option_value);
}
else { // radio buttons ?
- $selected = kUtil::unhtmlentities($options[$object->GetId()]) == $val;
+ $selected = kUtil::unhtmlentities($option_value) == $val;
}
}
- if ($selected) {
- if ($mode == 'selected') {
- if ($object->GetDBField('OptionType') != 6) {
+
+ if ( $selected ) {
+ if ( $mode == 'selected' ) {
+ if ( $object->GetDBField('OptionType') != OptionType::CHECKBOX ) {
$block_params['selected'] = ' selected="selected" ';
}
else {
$block_params['selected'] = ' checked="checked" ';
}
}
else {
switch ($object->GetDBField('OptionType')) {
- case 1: //drop-down
+ case OptionType::DROPDOWN:
$block_params['selected'] = ' selected="selected" ';
break;
- case 3: //radio
- case 6: //checkboxes
+ case OptionType::RADIO:
+ case OptionType::CHECKBOX:
$block_params['selected'] = ' checked="checked" ';
break;
}
}
}
else {
$block_params['selected'] = '';
}
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function &GetOptions()
{
$opt_data = $this->Application->GetVar('options');
$options = getArrayValue($opt_data, $this->Application->GetVar('p_id'));
if (!$options && $this->Application->GetVar('orditems_id')) {
$ord_item =& $this->Application->recallObject('orditems.-opt', null, Array ('skip_autoload' => true));
/* @var $ord_item kDBItem */
$ord_item->Load($this->Application->GetVar('orditems_id'));
$item_data = unserialize($ord_item->GetDBField('ItemData'));
$options = getArrayValue($item_data, 'Options');
}
return $options;
}
function OptionData($params)
{
$object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
$options =& $this->GetOptions();
- return getArrayValue($options, $object->GetId());
+
+ return getArrayValue($options, $object->GetID());
}
function ListOptions($params)
{
return $this->PrintList2($params);
}
}
\ No newline at end of file

Event Timeline