本文整理汇总了PHP中Shop::setFlash方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::setFlash方法的具体用法?PHP Shop::setFlash怎么用?PHP Shop::setFlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::setFlash方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate()
{
if (!is_numeric($_POST['amount']) || $_POST['amount'] <= 0) {
Shop::setFlash(Shop::t('Illegal amount given'));
$this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
}
if (isset($_POST['Variations'])) {
foreach ($_POST['Variations'] as $key => $variation) {
$specification = ProductSpecification::model()->findByPk($key);
if ($specification->required && $variation[0] == '') {
Shop::setFlash(Shop::t('Please select a {specification}', array('{specification}' => $specification->title)));
$this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
}
}
}
$cart = Shop::getCartContent();
// remove potential clutter
if (isset($_POST['yt0'])) {
unset($_POST['yt0']);
}
if (isset($_POST['yt1'])) {
unset($_POST['yt1']);
}
$cart[] = $_POST;
Shop::setCartcontent($cart);
Shop::setFlash(Shop::t('The product has been added to the shopping cart'));
$this->redirect(array('//shop/products/index'));
}
示例2: actionCreate
public function actionCreate()
{
// if some data has been entered before or the user is already logged in,
// take the already existing data and prefill the input form
if ($model = Shop::getCustomer()) {
$address = $model->address;
} else {
$model = new Customer();
}
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
if (isset($_POST['Address'])) {
$address = new Address();
$address->attributes = $_POST['Address'];
if ($address->save()) {
$model->address_id = $address->id;
}
}
if (!Yii::app()->user->isGuest) {
$model->user_id = Yii::app()->user->id;
}
$model->validate();
if (Shop::module()->useWithYum && isset($_POST['register']) && ($_POST['register'] = true)) {
if (isset($_POST['Customer']['password']) && isset($_POST['Customer']['passwordRepeat'])) {
if ($_POST['Customer']['password'] != $_POST['Customer']['passwordRepeat']) {
$model->addError('password', Shop::t('Passwords do not match'));
} else {
if ($_POST['Customer']['password'] == '') {
$model->addError('password', Shop::t('Password is empty'));
} else {
$user = new YumUser();
$profile = new YumProfile();
$profile->attributes = $_POST['Customer'];
$profile->attributes = $_POST['Address'];
if ($user->register(strtr($model->email, array('@' => '_', '.' => '_')), $_POST['Customer']['password'], $profile)) {
$user->status = YumUser::STATUS_ACTIVE;
$user->save(false, array('status'));
$model->user_id = $user->id;
Shop::setFlash(Shop::t('Successfully registered user'));
} else {
$model->addErrors($user->getErrors());
$model->addErrors($profile->getErrors());
Shop::setFlash(Shop::t('Error while registering user'));
}
}
}
}
}
if (!$model->hasErrors()) {
if ($model->save()) {
Yii::app()->user->setState('customer_id', $model->customer_id);
$this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
}
}
}
$this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
}
示例3: actionPaypal
public function actionPaypal($order_id = null)
{
$model = new PayPalForm();
if ($order_id !== null) {
$model->order_id = $order_id;
}
$order = Order::model()->findByPk($model->order_id);
if ($order->customer->user_id != Yii::app()->user->id) {
throw new CHttpException(403);
}
if ($order->status != 'new') {
Shop::setFlash('The order is already paid');
$this->redirect('//shop/products/index');
}
if (isset($_POST['PayPalForm'])) {
$model->attributes = $_POST['PayPalForm'];
if ($model->validate()) {
echo $model->handlePayPal($order);
}
}
$this->render('/order/paypal_form', array('model' => $model));
}
示例4: actionConfirm
public function actionConfirm()
{
Yii::app()->user->setState('order_comment', @$_POST['Order']['Comment']);
if (isset($_POST['accept_terms']) && $_POST['accept_terms'] == 1) {
$order = new Order();
$customer = Shop::getCustomer();
$cart = Shop::getCartContent();
$order->customer_id = $customer->customer_id;
$address = new DeliveryAddress();
if ($customer->deliveryAddress) {
$address->attributes = $customer->deliveryAddress->attributes;
} else {
$address->attributes = $customer->address->attributes;
}
$address->save();
$order->delivery_address_id = $address->id;
$address = new BillingAddress();
if ($customer->billingAddress) {
$address->attributes = $customer->billingAddress->attributes;
} else {
$address->attributes = $customer->address->attributes;
}
$address->save();
$order->billing_address_id = $address->id;
$order->ordering_date = time();
$order->payment_method = Yii::app()->user->getState('payment_method');
$order->shipping_method = Yii::app()->user->getState('shipping_method');
$order->comment = Yii::app()->user->getState('order_comment');
if ($order->save()) {
foreach ($cart as $position => $product) {
$position = new OrderPosition();
$position->order_id = $order->order_id;
$position->product_id = $product['product_id'];
$position->amount = $product['amount'];
$position->specifications = @json_encode($product['Variations']);
$position->save();
Yii::app()->user->setState('cart', array());
Yii::app()->user->setState('shipping_method', null);
Yii::app()->user->setState('payment_method', null);
Yii::app()->user->setState('order_comment', null);
}
Shop::mailNotification($order);
$this->redirect(Shop::module()->successAction);
} else {
$this->redirect(Shop::module()->failureAction);
}
} else {
Shop::setFlash(Shop::t('Please accept our Terms and Conditions to continue'));
$this->redirect(array('//shop/order/create'));
}
}
示例5: actionCreate
public function actionCreate()
{
if (!is_numeric($_POST['amount']) || $_POST['amount'] <= 0) {
Shop::setFlash(Shop::t('Illegal amount given'));
$this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
}
if (isset($_POST['Variations'])) {
foreach ($_POST['Variations'] as $key => $variation) {
$specification = ProductSpecification::model()->findByPk($key);
if ($specification->required && $variation[0] == '') {
Shop::setFlash(Shop::t('Please select a {specification}', array('{specification}' => $specification->title)));
$this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
}
}
}
if (isset($_FILES)) {
foreach ($_FILES as $variation) {
$target = Shop::module()->uploadedImagesFolder . '/' . $variation['name'];
if ($variation['tmp_name'] == '') {
Shop::setFlash(Shop::t('Please select a image from your hard drive'));
$this->redirect(array('//shop/shoppingCart/view'));
}
if (move_uploaded_file($variation['tmp_name'], $target)) {
$_POST['Variations']['image'] = $target;
}
}
}
$cart = Shop::getCartContent();
// remove potential clutter
if (isset($_POST['yt0'])) {
unset($_POST['yt0']);
}
if (isset($_POST['yt1'])) {
unset($_POST['yt1']);
}
$cart[] = $_POST;
Shop::setCartcontent($cart);
Shop::setFlash(Shop::t('The product has been added to the shopping cart'));
$this->redirect(array('//shop/shoppingCart/view'));
}