Skip to content

Commit

Permalink
3000fc4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Thom White committed May 21, 2013
1 parent f480973 commit fbd893e
Show file tree
Hide file tree
Showing 104 changed files with 1,849 additions and 857 deletions.
1 change: 0 additions & 1 deletion css/base.css
Expand Up @@ -138,7 +138,6 @@ em {

strong {
font-weight: bold;
color: #333;
}

small {
Expand Down
2 changes: 1 addition & 1 deletion framework/utils/CFileHelper.php
Expand Up @@ -284,7 +284,7 @@ private static function mkdir($dst,array $options,$recursive)
self::mkdir(dirname($dst),$options,true);

$mode=isset($options['newDirMode']) ? $options['newDirMode'] : 0777;
$res=mkdir($dst, $mode);
$res=@mkdir($dst, $mode);
chmod($dst,$mode);
return $res;
}
Expand Down
318 changes: 158 additions & 160 deletions install.php

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions js/checkout.js

This file was deleted.

9 changes: 0 additions & 9 deletions js/wishlist.js

This file was deleted.

6 changes: 1 addition & 5 deletions protected/components/Controller.php
Expand Up @@ -29,7 +29,6 @@ class Controller extends CController

/* These are public variables that are used in our layout, so we have to define them.
*/
public $pageLanguage;
public $pageDescription;
public $pageCanonicalUrl;
public $pageImageUrl;
Expand Down Expand Up @@ -87,7 +86,6 @@ public function init() {

$this->pageTitle =
Yii::app()->name = _xls_get_conf('STORE_NAME', 'LightSpeed Web Store');
$this->pageLanguage = _xls_get_conf('LANG_CODE', 'en');
$this->pageCanonicalUrl = $this->getCanonicalUrl();
$this->pageDescription = _xls_get_conf('STORE_TAGLINE');
$this->pageImageUrl ='';
Expand All @@ -106,9 +104,7 @@ public function init() {
Yii::app()->end();
}

//$this->menuwidget = $this->widget('application.extensions.wsmenu.wsmenu');

//$this->searchPnl=$this->renderPartial('search',array(),true);
Yii::app()->shoppingcart->UpdateMissingProducts();

//Run other functions to create some data we always need
$this->buildGoogle();
Expand Down
4 changes: 1 addition & 3 deletions protected/components/FBIdentity.php
Expand Up @@ -63,9 +63,7 @@ public function authenticate()

//New user to our site using Facebook, so set up an account
$model = new Customer();
$model->scenario = 'create';
$model->password = "facebook";
$model->password_repeat = "facebook";
$model->scenario = 'createfb';
$results = Yii::app()->facebook->api('/me');
$model->first_name = $results['first_name'];
$model->last_name = $results['last_name'];
Expand Down
74 changes: 67 additions & 7 deletions protected/components/ShoppingCart.php
Expand Up @@ -56,20 +56,22 @@ public function getModel()
if (!is_null($intCustomerid))
$objCart = Cart::LoadLastCartInProgress($intCustomerid);
if (is_null($objCart))
$objCart = Cart::InitializeCart();

Yii::app()->user->setState('cartid',$objCart->id);
$objCart = new Cart();

//Logged in customers get a "real" cart
if(is_null($objCart) && !is_null($intCustomerid))
{
$objCart = Cart::InitializeCart();
Yii::app()->user->setState('cartid',$objCart->id);
}

} else {

$objCart = Cart::model()->findByPk($intCartId);
if (!$objCart) {
//something has happened to the database object
Yii::log("Could not find cart ".$intCartId.", creating new one.", 'error', 'application.'.__CLASS__.".".__FUNCTION__);
//unset(Yii::app()->session['cartid']);
$objCart = Cart::InitializeCart();
//Yii::app()->session['cartid'] = $objCart->id;
Yii::app()->user->setState('cartid',$objCart->id);
}

Expand All @@ -80,6 +82,34 @@ public function getModel()
return $this->_model;
}


/**
* Since calling our model doesn't necessarily really create a db record (to avoid blank carts all over the place),
* this function purposely creates a record when we need one (i.e. when adding a product to the cart)
*/
protected function createCart()
{
$intCartId = Yii::app()->user->getState('cartid');

if(empty($intCartId)) {

$objCustomer = Customer::GetCurrent();
$intCustomerid = null;

if ($objCustomer instanceof Customer)
$intCustomerid = $objCustomer->id;

$objCart = null;
if (!is_null($intCustomerid))
$objCart = Cart::LoadLastCartInProgress($intCustomerid);
if (is_null($objCart))
$objCart = Cart::InitializeCart();

$this->_model = $objCart;
Yii::app()->user->setState('cartid',$objCart->id);
}
}

public function getIsActive()
{
if (!$this->_model)
Expand All @@ -105,7 +135,8 @@ public function loginMerge($objCartToMerge = null)
$arrPastItems = $objCartInProgress->cartItems;

//Merge in any new items we had in our cart from this session
if (count($arrPastItems)>0) {
if (count($arrPastItems)>0)
{
foreach($arrPastItems as $objItem) {
$objProduct = Product::model()->findbyPk($objItem->product_id);
$this->model->AddToCart($objProduct,$objItem->qty,$objItem->description,
Expand All @@ -117,6 +148,7 @@ public function loginMerge($objCartToMerge = null)
Yii::app()->user->setFlash('success',Yii::t('cart','Your prior cart has been restored.'));
$objCartInProgress->delete();
}
$this->model->UpdateMissingProducts();
}

}
Expand Down Expand Up @@ -245,12 +277,18 @@ public function setTaxCodeId($id)
*/
public function addProduct($mixProduct,$intQuantity = 1,$intGiftItemId = null, $auto=null)
{
$cartid=Yii::app()->user->getState('cartid');
if (empty($cartid))
$this->createCart();

if ($mixProduct instanceof Product)
$objProduct = $mixProduct;
else
$objProduct = Product::model()->findByPk($mixProduct);

if(!(_xls_get_conf('QTY_FRACTION_PURCHASE')))
$intQuantity = intval($intQuantity);

if ($objProduct instanceof Product)
{
$this->clearCachedShipping();
Expand Down Expand Up @@ -287,9 +325,16 @@ public function cartItems()
*/
public function save()
{
return $this->model->save();
$retVal = $this->model->save();
if (!$retVal)
Yii::log("Error saving cart ".print_r($this->model->getErrors()), 'error', 'application.'.__CLASS__.".".__FUNCTION__);
return $retVal;
}

public function getErrors()
{
return $this->model->getErrors();
}
/**
* Create a Link to view the cart after checkout. Used for receipt viewing.
* @return mixed
Expand Down Expand Up @@ -326,6 +371,16 @@ public function clearCart()
return true;
}


public function UpdateMissingProducts()
{

if( Yii::app()->user->getState('cartid')>0)
$this->model->UpdateMissingProducts();

}


/**
* Disassociate the cart with the current session. Should be done after payment
* is complete but before redirecting to receipt.
Expand Down Expand Up @@ -485,6 +540,11 @@ public function __get($strName) {
case 'TaxTotal':
return $this->model->TaxTotal;

case 'subtotal':
if (empty($this->model->subtotal))
return 0;
else return $this->model->subtotal;

case 'Taxes':
return $this->model->Taxes;

Expand Down
18 changes: 17 additions & 1 deletion protected/components/helpers.php
Expand Up @@ -54,6 +54,22 @@ function _xls_site_url($strUrlPath = '') {
return _xls_site_dir($usessl) . '/' . $strUrlPath;
}

function _xls_regionalize($str)
{
$c = Yii::app()->params['DEFAULT_COUNTRY'];
switch ($str)
{
case 'color':
if ($c==224) return 'color'; else return 'colour';

case 'check':
if ($c==224) return 'check'; else return 'cheque';

default:
return $str;
}
}

/**
* Return the Base URL for the site
* Also perform http/https conversion if need be.
Expand Down Expand Up @@ -134,7 +150,7 @@ function _xls_raise_events($strEvent,$objEvent)

//Raise events
foreach ($objModules as $objModule) {
Yii::log('Running event '.$objEvent->onAction.' '.$objModule->module, 'info', 'application.'.__CLASS__.".".__FUNCTION__);
Yii::log('Running event '.$strEvent.' '.$objModule->module, 'info', 'application.'.__CLASS__.".".__FUNCTION__);
$objModule->instanceHandle->raiseEvent($objEvent->onAction,$objEvent);
}
}
Expand Down
4 changes: 2 additions & 2 deletions protected/config/_main.php
Expand Up @@ -26,8 +26,8 @@
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Web Store',
//'theme'=>'brooklyn', //pulled from wsconfig
'language' => 'en_us',
'sourceLanguage' => 'en_us',
//'language' => 'en', //pulled from wsconfig
'sourceLanguage' => 'en',

// preloading 'log' component
'preload'=>array(
Expand Down
2 changes: 1 addition & 1 deletion protected/config/wsver.php
@@ -1,4 +1,4 @@
<?php

define('XLSWS_VERSION', '3.0.0fc1');
define('XLSWS_VERSION', '3.0.0fc4');
define('XLSWS_VERSIONBUILD', 3000);
39 changes: 22 additions & 17 deletions protected/controllers/CartController.php
Expand Up @@ -422,11 +422,6 @@ public function actionEmail()
public function actionCheckout()
{


Yii::app()->clientScript->registerScriptFile(
Yii::app()->baseUrl.'/js/checkout.js'
);

//We shouldn't be in this controller if we don't have any products in our cart
if (!Yii::app()->shoppingcart->itemCount)
{
Expand Down Expand Up @@ -876,18 +871,27 @@ public function actionCheckout()
$objPaymentModule = Modules::model()->findByPk($model->paymentProvider);
if ($objPaymentModule instanceof Modules)
{
$subForm = Yii::app()->getComponent($objPaymentModule->module)->subform;
if(isset($subForm))
if (isset($_POST[$subForm]))
{
$paymentForms[$objPaymentModule->id]->attributes = $_POST[$subForm];
$paymentForms[$objPaymentModule->id]->validate();
}
$objModule = Yii::app()->getComponent($objPaymentModule->module);
if (!$objModule)
{
Yii::log("Error missing module ".$objPaymentModule->module, 'error', 'application.'.__CLASS__.".".__FUNCTION__);
$model->paymentProvider=null;
}
else
{
$subForm = $objModule->subform;
if(isset($subForm))
if (isset($_POST[$subForm]))
{
$paymentForms[$objPaymentModule->id]->attributes = $_POST[$subForm];
$paymentForms[$objPaymentModule->id]->validate();
}

Yii::app()->clientScript->registerScript('payment',
'$(document).ready(function(){
changePayment(\''.$objPaymentModule->id.'\')
});');
Yii::app()->clientScript->registerScript('payment',
'$(document).ready(function(){
changePayment(\''.$objPaymentModule->id.'\')
});');
}
} else $model->paymentProvider=null;
}

Expand Down Expand Up @@ -1101,7 +1105,7 @@ public function EmailReceipts($objCart)
if (_xls_get_conf('EMAIL_SEND_STORE',0)==1) {
$strHtmlBody =$this->renderPartial('/mail/_customerreceipt', array('cart'=>$objCart), true);
$strSubject = _xls_format_email_subject(
'EMAIL_SUBJECT_CUSTOMER',$objCart->customer->first_name.' '.$objCart->customer->last_name,
'EMAIL_SUBJECT_OWNER',$objCart->customer->first_name.' '.$objCart->customer->last_name,
$objCart->id_str
);

Expand Down Expand Up @@ -1400,6 +1404,7 @@ public function actionApplyPromocode()

}


/**
* Called by AJAX function from checkout for Calculate Shipping. Builds a grid of shipping scenarios including
* shipping price and cart total prices. The results are cached client-side in the browser allowing the
Expand Down

0 comments on commit fbd893e

Please sign in to comment.