Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
3.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaz committed Jun 16, 2015
1 parent 33f5304 commit 3984def
Show file tree
Hide file tree
Showing 81 changed files with 9,930 additions and 1,800 deletions.
43 changes: 0 additions & 43 deletions core/protected/components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,49 +562,6 @@ public function getReturnUrl()
return Yii::app()->session['returnUrl'];
}

/**

This comment has been minimized.

Copy link
@peteles

peteles Jun 29, 2015

Hello, I was wondering why this method has been removed instead of deprecated?

This comment has been minimized.

Copy link
@gabeguz

gabeguz Jun 29, 2015

Hi @peteles -- sorry about that, this function got refactored into the ProductGrid.php component as it makes more sense for it to live there than bundled with the general Controller. We don't have a deprecation strategy with regards to internal functions at the moment, but I'll bring it up during our next retrospective. Let us know if ProductGrid::createBookends() doesn't work for you.

This comment has been minimized.

Copy link
@peteles

peteles via email Jun 30, 2015

* Cycle through Product model for page and mark beginning and end of each row.
*
* Used for <div row> formatting in the view layer.
*
* @param $model
* @return mixed
*/
protected function createBookends($model)
{
if (count($model) == 0 || Yii::app()->theme->config->disableGridRowDivs)
{
return $model;
}

$ct = -1;
$next = 0;
foreach ($model as $item)
{
$ct++;
if ($ct == 0)
{
$model[$ct]->rowBookendFront = true;
}

if ($next == 1)
{
$model[$ct]->rowBookendFront = true;
$next = 0;
}

if ((1 + $ct) % $this->gridProductsPerRow == 0)
{
$model[$ct]->rowBookendBack = true;
$next = 1;
}
}

$model[count($model) - 1]->rowBookendBack = true; //Last item must always close div
return $model;
}


protected function afterRender($view, &$output) {
parent::afterRender($view, $output);
//Yii::app()->facebook->addJsCallback($js); // use this if you are registering any $js code you want to run asyc
Expand Down
153 changes: 153 additions & 0 deletions core/protected/components/ProductGrid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

/**
* Class ProductGrid
* This class generates the array needed to display web store products in a
* grid. This class also contains the pagination information for customers to
* navigated products displayed. The product grid is based on certain criteria
* applied against the xlsws_product table.
*/
class ProductGrid
{
/**
* This holds the criteria that the grid needs
* to display itself. This criteria runs against
* the product model and the pagination object.
*
* @var CDbCriteria
*/
private $_productGridCriteria;

/**
* This variable holds the pagination information
* for the grid. The criteria is passed to it to know
* how many pages are needed to display all the products.
*
* @var CPagination
*/
private $_pages;

/**
* This contains a subset of the products. Only the products
* in the current page will be in that array.
*
* @var Product[]
*/
private $_productsGrid;

/**
* Holds the number of products that the entire grid holds.
* This is a count of all the products based on the criteria.
*
* @var int
*/
private $_numberOfRecords;

/**
* Based on a criteria, this will generate the products
* grid to be displayed on the page.
* @param CDbCriteria $criteria A criteria object that determines
* which products to get from the DB.
*/
public function __construct($criteria)
{
if ($criteria instanceof CDbCriteria === false)
{
$criteria = new CDbCriteria();
}

$this->_productGridCriteria = $criteria;
$this->generateProductGrid();
}

/**
* This function generates the products grid
* based on the criteria. It also generates the
* pagination object need for the users to navigate
* through products.
*
* @return void
*/
public function generateProductGrid()
{
$this->_numberOfRecords = Product::model()->count(
$this->_productGridCriteria
);

$this->_pages = new CPagination($this->_numberOfRecords);
$this->_pages->setPageSize(
CPropertyValue::ensureInteger(Yii::app()->params['PRODUCTS_PER_PAGE'])
);
$this->_pages->applyLimit($this->_productGridCriteria);

$this->_productsGrid = self::createBookends(
Product::model()->findAll($this->_productGridCriteria)
);
}

/**
* This function returns a CPagination object needed to display
* pagination for the products grid
*
* @return CPagination
*/
public function getPages()
{
return $this->_pages;
}

/**
* This function returns an object containing the product
* grid.
*
* @return mixed
*/
public function getProductGrid()
{
return $this->_productsGrid;
}

/**
* This function returns the number of products return by the query.
* This count is based on the product grid criteria.
*
* @return int
*/
public function getNumberOfRecords()
{
return $this->_numberOfRecords;
}

/**
* Cycle through Product model for page and mark beginning and end of each row.
*
* Used for <div row> formatting in the view layer.
*
* @param $model
* @return mixed
*/
public static function createBookends($objProducts)
{
$gridProductsPerRow = _xls_get_conf('PRODUCTS_PER_ROW', 3);
if (count($objProducts) == 0 || Yii::app()->theme->config->disableGridRowDivs)
{
return $objProducts;
}

foreach ($objProducts as $idx => $item)
{
switch ($idx % $gridProductsPerRow)
{
case 0:
$objProducts[$idx]->rowBookendFront = true;
break;
case $gridProductsPerRow - 1:
$objProducts[$idx]->rowBookendBack = true;
break;
}
}

end($objProducts)->rowBookendBack = true; //Last item must always close div
return $objProducts;
}
}
2 changes: 1 addition & 1 deletion core/protected/components/ShoppingCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function loginQuote($objDocument = null)
$objItem->discount
);

if (strlen($retVal) > 5)
if (is_string($retVal) && strlen($retVal) > 5)
{
return $retVal;
}
Expand Down
3 changes: 2 additions & 1 deletion core/protected/components/WsWebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class WsWebApplication extends CWebApplication
'soap',
'legacysoap',
'commonssl',
'images'
'images',
'editcart'
);


Expand Down
4 changes: 3 additions & 1 deletion core/protected/components/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @return string key value
*/
// @codingStandardsIgnoreStart
function _xls_get_conf($strKey, $mixDefault = "")
function _xls_get_conf($strKey, $mixDefault = '')
// @codingStandardsIgnoreEnd
{

Expand Down Expand Up @@ -3255,3 +3255,5 @@ function arraySwap($array, $key1, $key2)

return $swappedArray;
}


6 changes: 3 additions & 3 deletions core/protected/config/wsver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

define('XLSWS_VERSION', '3.2.8');
define('XLSWS_VERSIONBUILD', 300200800);
define('XLSWS_BUILDDATE', 'webstore-2015-05-15-1249');
define('XLSWS_VERSION', '3.2.9');
define('XLSWS_VERSIONBUILD', 300200900);
define('XLSWS_BUILDDATE', 'webstore-2015-06-16-2039');
90 changes: 87 additions & 3 deletions core/protected/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,21 @@ public function actionQuote()
);
}

//And go to cart view
// Since the email link generated by OnSite references the CartController
// and this action, we must redirect to the proper cart view if the Web
// Store is using a theme on Advanced Checkout.
if (Yii::app()->theme->info->advancedCheckout === true)
{
Yii::app()->controller->redirect(Yii::app()->createUrl('/editcart'));
}

// And go to cart view
Yii::app()->controller->redirect(Yii::app()->createUrl('cart'));
} else {
}
else
{
Yii::app()->user->setFlash('error', Yii::t('cart', 'Quote not found.'));

//Go to home page
Yii::app()->controller->redirect(Yii::app()->createUrl('site/index'));
}
Expand Down Expand Up @@ -1723,7 +1734,11 @@ public function actionGetDestinationStates()

/**
* When a shopper changes the state or postal/zip which affects tax,
* recalculate scenarios and send back to browser
* recalculate scenarios and send back to browser.
*
* @deprecated 3.2.9 This was deprecated in Web Store 3.2.9. Some countries
* do not have any states and therefore it is not possible to look up the
* country by state_id. Use setTaxByAddress instead.
*/
public function actionSetTax()
{
Expand All @@ -1736,6 +1751,14 @@ public function actionSetTax()
$strPostal = Yii::app()->getRequest()->getParam('postal');
$objState = State::Load($intStateId);

if ($objState === null)
{
throw new CHttpException(
400,
Yii::t('application errors', 'Invalid state_id.')
);
}

Yii::app()->shoppingcart->setTaxCodeByAddress(
$objState->country_code,
$objState->code,
Expand All @@ -1751,6 +1774,67 @@ public function actionSetTax()
return $this->renderJSON($arrReturn);
}

/**
* Set the cart tax code based on an address.
* The country_id parameter is required, state_id and postal are optional.
*/
public function actionSetTaxByAddress()
{
$intCountryId = Yii::app()->getRequest()->getParam('country_id');
$intStateId = Yii::app()->getRequest()->getParam('state_id', '');
$strPostal = Yii::app()->getRequest()->getParam('postal', '');

$objCountry = Country::Load($intCountryId);

if ($objCountry === null)
{
throw new CHttpException(
400,
Yii::t('application errors', 'Invalid country_id.')
);
}

$strStateCode = null;
if ($intStateId !== '')
{
$objState = State::Load($intStateId);

if ($objState === null)
{
throw new CHttpException(
400,
Yii::t('application errors', 'Invalid state_id.')
);
}

// Validate the state/country combination.
$arrShippingStates = Country::getCountryShippingStates($intCountryId);
if (array_key_exists($intStateId, $arrShippingStates) === false)
{
throw new CHttpException(
400,
Yii::t('application errors', 'The state_id is not valid for the country_id.')
);
}

$strStateCode = $objState->code;
}

Yii::app()->shoppingcart->setTaxCodeByAddress(
$objCountry->code,
$strStateCode,
$strPostal
);

$arrReturn['cartitems'] = $this->renderPartial('/cart/_cartitems', null, true);
if (Yii::app()->session->get('ship.prices.cache', null) !== null)
{
$arrReturn['action'] = 'triggerCalc';
}

return $this->renderJSON($arrReturn);
}

/**
* Ajax receiver function to Add To Cart.
* This function adds to the cart and then returns a JSON encoded string of
Expand Down
3 changes: 2 additions & 1 deletion core/protected/controllers/MyaccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function actionIndex()
}

// New styles, javascript and layout for Brooklyn2014
if (Yii::app()->theme->name === 'brooklyn2014')
if (Yii::app()->theme->info->advancedCheckout &&
Yii::app()->theme->info->version > 5)
{
$this->widget('ext.umber.wsmodal');
$this->widget('ext.wsaccount.wsaccount');
Expand Down
Loading

0 comments on commit 3984def

Please sign in to comment.