本文整理汇总了PHP中Customer::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::update方法的具体用法?PHP Customer::update怎么用?PHP Customer::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent()
{
if (Tools::isSubmit('submitUpdate')) {
Configuration::updateValue('NW_CONFIRMATION_EMAIL', (bool) Tools::getValue('NW_CONFIRMATION_EMAIL'));
Configuration::updateValue('NW_VERIFICATION_EMAIL', (bool) Tools::getValue('NW_VERIFICATION_EMAIL'));
$voucher = Tools::getValue('NW_VOUCHER_CODE');
if ($voucher && !Validate::isDiscountName($voucher)) {
$this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
} else {
Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
}
} elseif (Tools::isSubmit('subscribedmerged')) {
$id = Tools::getValue('id');
if (preg_match('/(^N)/', $id)) {
$id = (int) substr($id, 1);
$sql = 'UPDATE ' . _DB_PREFIX_ . 'newsletter SET active = 0 WHERE id = ' . $id;
Db::getInstance()->execute($sql);
} else {
$c = new Customer((int) $id);
$c->newsletter = (int) (!$c->newsletter);
$c->update();
}
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&conf=4&token=' . Tools::getAdminTokenLite('AdminModules'));
} elseif (Tools::isSubmit('exportSubscribers')) {
$header = array('id', 'shop_name', 'gender', 'lastname', 'firstname', 'email', 'subscribed', 'subscribed_on');
// TODO
$array_to_export = array_merge(array($header), $this->getSubscribers());
$file_name = time() . '.csv';
$fd = fopen($this->getLocalPath() . $file_name, 'w+');
foreach ($array_to_export as $tab) {
$line = implode(';', $tab);
$line .= "\n";
fwrite($fd, $line, 4096);
}
fclose($fd);
Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
} elseif (Tools::isSubmit('exportOnlyBlockNews')) {
$array_to_export = $this->getBlockNewsletterSubscriber();
$file_name = time() . '.csv';
$fd = fopen($this->getLocalPath() . $file_name, 'w+');
foreach ($array_to_export as $tab) {
$line = implode(';', $tab);
$line .= "\n";
fwrite($fd, $line, 4096);
}
fclose($fd);
Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
} elseif (Tools::isSubmit('searchEmail')) {
$this->_searched_email = Tools::getValue('searched_email');
}
$this->_html .= $this->renderForm();
$this->_html .= $this->renderSearchForm();
$this->_html .= $this->renderList();
$this->_html .= '<div class="panel"><a href="' . $this->context->link->getAdminLink('AdminModules', false) . '&exportSubscribers&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
<button class="btn btn-default btn-lg"><span class="icon icon-share"></span> ' . $this->l('Export as CSV') . '</button>
</a></div>';
$this->_html .= $this->renderExportForm();
return $this->_html;
}
示例2: index
public function index()
{
$obj = new Customer('1');
$obj->fname = 'Altaf';
$obj->update();
//echo "<pre>";print_r($obj->getData);die;
}
示例3: preProcess
public function preProcess()
{
parent::preProcess();
$customer = new Customer((int) self::$cookie->id_customer);
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) {
$customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (Module::getInstanceByName('blocknewsletter')->active) {
if (!isset($_POST['optin'])) {
$customer->optin = 0;
}
if (!isset($_POST['newsletter'])) {
$customer->newsletter = 0;
}
}
if (!isset($_POST['id_gender'])) {
$_POST['id_gender'] = 9;
}
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
} else {
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$id_customer_exists = (int) Customer::customerExists(Tools::getValue('email'), true, false);
if ($id_customer_exists && $id_customer_exists != (int) self::$cookie->id_customer) {
$this->errors[] = Tools::displayError('An account is already registered with this e-mail.');
}
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
$this->errors[] = Tools::displayError('Your password is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('Password and confirmation do not match');
} else {
$prev_id_default_group = $customer->id_default_group;
$this->errors = array_unique(array_merge($this->errors, $customer->validateController(true, true)));
}
if (!count($this->errors)) {
$customer->id_default_group = (int) $prev_id_default_group;
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd')) {
self::$cookie->passwd = $customer->passwd;
}
if ($customer->update()) {
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('Cannot update information');
}
}
}
} else {
$_POST = array_map('stripslashes', $customer->getFields());
}
$birthday = $customer->birthday ? explode('-', $customer->birthday) : array('-', '-', '-');
/* Generate years, months and days */
self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors));
self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
}
示例4: testCustomerUpdateFromCard
public function testCustomerUpdateFromCard()
{
$token = 'cus_FaWhNhFT5gEAAv5BArjJSIIq';
$this->mockResponse($this->success_customer_update_card_response());
$params = array('card_number' => '4908440000000003', 'expiration_month' => '01', 'expiration_year' => date('Y') + 1, 'cvv' => '123', 'holder_name' => 'John Doe');
$customer = Customer::update($token, $params);
$this->assertEquals(substr($params['card_number'], -4), $customer->card->last_four);
}
示例5: testCustomerUpdate
public function testCustomerUpdate()
{
$token = 'cus_zDdjHBuNW3do8G3jaTqApzsI';
$this->mockResponse($this->success_customer_update_response());
$params = array('email' => 'john_dow@example.com', 'full_name' => 'John Doe');
$customer = Customer::update($token, $params);
$this->assertNotNull($customer->email);
$this->assertNotNull($customer->full_name);
}
示例6: preProcess
public function preProcess()
{
parent::preProcess();
$customer = new Customer((int) self::$cookie->id_customer);
if (sizeof($_POST)) {
$exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add', 'id_default_group');
$fields = $customer->getFields();
foreach ($fields as $key => $value) {
if (!in_array($key, $exclusion)) {
$customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
}
}
}
if (isset($_POST['years']) and isset($_POST['months']) and isset($_POST['days'])) {
$customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
} else {
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) or Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
$this->errors[] = Tools::displayError('Your password is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('Password and confirmation do not match');
} else {
$prev_id_default_group = $customer->id_default_group;
$this->errors = $customer->validateControler();
}
if (!sizeof($this->errors)) {
$customer->id_default_group = (int) $prev_id_default_group;
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd')) {
self::$cookie->passwd = $customer->passwd;
}
if ($customer->update()) {
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('Cannot update information');
}
}
}
} else {
$_POST = array_map('stripslashes', $customer->getFields());
}
if ($customer->birthday) {
$birthday = explode('-', $customer->birthday);
} else {
$birthday = array('-', '-', '-');
}
/* Generate years, months and days */
self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors));
self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
}
示例7: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('email')) {
if (!($email = Tools::getValue('email')) || !Validate::isEmail($email)) {
$this->errors[] = Tools::displayError('Invalid e-mail address');
} else {
$customer = new Customer();
$customer->getByemail($email);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
} else {
if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
$this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int) $min_time);
} else {
if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id)), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
} else {
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
}
}
}
} else {
if (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
$email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer=' . (int) $id_customer);
if ($email) {
$customer = new Customer();
$customer->getByemail($email);
if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
Tools::redirect('index.php?controller=authentication&error_regen_pwd');
} else {
$customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH));
$customer->last_passwd_gen = date('Y-m-d H:i:s', time());
if ($customer->update()) {
Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
} else {
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
}
}
} else {
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
} else {
if (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer'))) {
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
}
}
}
示例8: update_models
public static function update_models($action, array $fromData, Customer $toMember)
{
$updateData = [];
foreach ($fromData as $fieldName => $value) {
// TODO what if we have a field with an underscore?
$updateData[str_replace('_', '.', $fieldName)] = $value;
}
$updateData = self::filter_data($action, $updateData);
$toMember->update($updateData);
$toMember->write();
return $fromData;
}
示例9: customer_edit
function customer_edit()
{
$customer = new Customer();
$customerid = isset($_POST['customerid']) ? $_POST['customerid'] : "";
$customer->id = $customerid;
$customer->name = isset($_POST['name']) ? $_POST['name'] : "";
$customer->address = isset($_POST['address']) ? $_POST['address'] : "";
$customer->phone = isset($_POST['phone']) ? $_POST['phone'] : "";
$customer->cell = isset($_POST['cell']) ? $_POST['cell'] : "";
$customer->active = isset($_POST['active']) ? $_POST['active'] : 0;
$customer->email = isset($_POST['email']) ? $_POST['email'] : "";
$customer->nit = isset($_POST['nit']) ? $_POST['nit'] : "";
return $customer->update();
}
示例10: anonimize_customers
public static function anonimize_customers()
{
$customers = Customer::getCustomers();
foreach ($customers as $customer) {
// print_r($customer);
$anon_customer = new Customer($customer["id_customer"]);
$anon_customer->email = md5($customer['email']) . '@example.com';
$res = $anon_customer->update();
if ($res) {
echo "Successfully updated user " . $anon_customer->id . "\n";
} else {
echo "Error, could not update user " . $customer['id_customer'] . "\n";
return false;
}
}
}
示例11: sqlInjection
<?php
session_start();
require "../deny/connector.php";
require "../administrator/process/class/class.Customer.php";
require "../administrator/includes/injection.php";
$cid = $_SESSION['user_id'];
$fullname = sqlInjection($_POST['fullname']);
$phone = sqlInjection($_POST['phone']);
$address = sqlInjection($_POST['address']);
$gender = sqlInjection($_POST['gender']);
//echo $cid." ".$fullname." ".$phone." ".$address." ".$gender;
$cus = new Customer();
$cus->update($cid, $fullname, $gender, $address, $phone);
echo "<meta http-equiv='refresh' content='0;url=../index.php?page=profile'>";
//header("location: ../index.php?page=profile");
//exit();
示例12: addWithemail
public function addWithemail($autodate = true, $templateVars = false)
{
$lastOrderState = $this->getLastOrderState($this->id_order);
if (!parent::add($autodate)) {
return false;
}
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . '
AND os.`send_email` = 1');
$order = new Order((int) $this->id_order);
if (isset($result['template']) and Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order);
if ($templateVars) {
$data = array_merge($data, $templateVars);
}
$data['{total_paid}'] = Tools::displayPrice((double) $order->total_paid, new Currency((int) $order->id_currency), false);
$data['{order_name}'] = sprintf("#%06d", (int) $order->id);
// An additional email is sent the first time a virtual item is validated
if ($virtualProducts = $order->getVirtualProducts() and (!$lastOrderState or !$lastOrderState->logable) and $newOrderState = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT')) and $newOrderState->logable) {
global $smarty;
$assign = array();
foreach ($virtualProducts as $key => $virtualProduct) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtualProduct['product_id']);
$product_download = new ProductDownload($id_product_download);
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtualProduct['download_hash']) . '&id_order=' . $order->id . '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtualProduct['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtualProduct['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
$smarty->assign('virtualProducts', $assign);
$smarty->assign('id_order', $order->id);
$iso = Language::getIsoById((int) $order->id_lang);
$links = $smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmpArray = array('{nbProducts}' => count($virtualProducts), '{virtualProducts}' => $links);
$data = array_merge($data, $tmpArray);
global $_LANGMAIL;
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('Virtual product to download'), $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
//custom subjects
$emailSubject = $topic;
$smsText = '';
$delivery = new Address((int) $order->id_address_delivery);
if ($this->id_order_state == _PS_OS_CANCELED_) {
$emailSubject = 'Your order #' . $order->id . ' with IndusDiva.com has been cancelled';
$smsText = 'Dear customer, your order #' . $order->id . ' with IndusDiva.com has been cancelled. www.indusdiva.com';
Tools::sendSMS($delivery->phone_mobile, $smsText);
} else {
if ($this->id_order_state == _PS_OS_REFUND_) {
$emailSubject = 'Refund of your payment at IndusDiva.com';
$smsText = 'Dear customer, an amount of ' . Tools::displayPrice((double) $order->total_paid) . ' has been credited to your account against your order #' . $order->id . ' at IndusDiva.com. www.indusdiva.com';
Tools::sendSMS($delivery->phone_mobile, $smsText);
}
}
if (Validate::isLoadedObject($order)) {
Mail::Send((int) $order->id_lang, $result['template'], $emailSubject, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname']);
}
}
/* Send loyalty rules message */
if ($this->id_order_state == _PS_OS_DELIVERED_) {
$customer = new Customer($order->id_customer);
$customer->total_delivered++;
$customer->update();
Tools::sendSQSRuleMessage(EVENT_ORDER_DELIVERED, $order->id, $order->id_customer, $this->date_add);
} else {
if ($this->id_order_state == _PS_OS_CANCELED_) {
$order_cart = new Cart($order->id_cart);
$points_redeemed = $order_cart->getPoints();
if ($points_redeemed) {
VBRewards::addRewardPoints($order->id_customer, EVENT_ORDER_CANCELLED, 0, $points_redeemed, 'Redemption order cancelled - Order no ' . $order->id, $order->id, $order->date_add);
}
/*
//if online payment bonus awarded
$reward = rule_base::getReward($order->id_customer, ONLINE_ORDER, 0, $order->id);
if($reward)
{
$points_removed = $reward['points_awarded'];
VBRewards::removeRewardPoints($order->id_customer, EVENT_ORDER_CANCELLED, 0, $points_removed, 'Order Cancellation - Bonus coins reverted - Order no ' . $order->id, $order->id, $this->date_add);
}
*/
//if the order was delivered
if ($lastOrderState->id == _PS_OS_DELIVERED_) {
$customer = new Customer($order->id_customer);
$customer->total_delivered--;
$customer->update();
Tools::sendSQSRuleMessage(EVENT_ORDER_CANCELLED, $order->id, $order->id_customer, $this->date_add);
}
} else {
if ($this->id_order_state == _PS_OS_PREPARATION_) {
//.........这里部分代码省略.........
示例13: die
die($pdoException->getMessage());
}
$customer = new Customer($dirt, 4);
echo "Number of columns: " . (string) $customer->getColumnCount() . "\n";
for ($i = 1; $i <= 1225; $i++) {
$isLoaded = $customer->retrieve(['Id' => $i]);
if ($isLoaded) {
echo 'Pharmacy Id: ' . (string) $customer->PharmacyId . "\n";
echo 'First Name: ' . $customer->FirstName . "\n";
echo 'Last Name: ' . $customer->LastName . "\n";
echo 'Email: ' . $customer->Email . "\n";
}
}
exit;
$customer->FirstName = 'Marge';
$updateWorked = $customer->update();
echo "Update: " . (string) $updateWorked;
exit;
$customer->FirstName = 'Ralph';
$customer->LastName = 'Bednar';
echo "Last Name: " . $customer->LastName;
$customer->bogus = 'ee';
exit;
/*
$dirtLite = $dirt->sqlite('/home/ryan/blah.db');
//$stmt = $dirtLite->query("CREATE TABLE Test (id int, firstname char(10))");
//$stmt->execute();
$stmt = $dirtLite->query("INSERT INTO Test (id, firstname) values(1,'ryan')");
示例14: preProcess
public function preProcess()
{
parent::preProcess();
if ($this->nbProducts) {
self::$smarty->assign('virtual_cart', false);
}
$this->isLogged = (bool) ((int) self::$cookie->id_customer and Customer::customerIdExistsStatic((int) self::$cookie->id_customer));
if (self::$cart->nbProducts()) {
if (Tools::isSubmit('ajax')) {
if (Tools::isSubmit('method')) {
switch (Tools::getValue('method')) {
case 'updateMessage':
if (Tools::isSubmit('message')) {
$txtMessage = urldecode(Tools::getValue('message'));
$this->_updateMessage($txtMessage);
if (sizeof($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
die(true);
}
break;
case 'updateCarrierAndGetPayments':
if (Tools::isSubmit('id_carrier') and Tools::isSubmit('recyclable') and Tools::isSubmit('gift') and Tools::isSubmit('gift_message')) {
if ($this->_processCarrier()) {
$return = array('summary' => self::$cart->getSummaryDetails(), 'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods());
die(Tools::jsonEncode($return));
} else {
$this->errors[] = Tools::displayError('Error occurred updating cart.');
}
if (sizeof($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
exit;
}
break;
case 'updateTOSStatusAndGetPayments':
if (Tools::isSubmit('checked')) {
self::$cookie->checkedTOS = (int) Tools::getValue('checked');
die(Tools::jsonEncode(array('HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods())));
}
break;
case 'getCarrierList':
die(Tools::jsonEncode($this->_getCarrierList()));
break;
case 'editCustomer':
if (!$this->isLogged) {
exit;
}
$customer = new Customer((int) self::$cookie->id_customer);
if (Tools::getValue('years')) {
$customer->birthday = (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days');
}
$_POST['lastname'] = $_POST['customer_lastname'];
$_POST['firstname'] = $_POST['customer_firstname'];
$this->errors = $customer->validateControler();
$customer->newsletter = (int) Tools::isSubmit('newsletter');
$customer->optin = (int) Tools::isSubmit('optin');
$return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) self::$cookie->id_customer, 'token' => Tools::getToken(false));
if (!sizeof($this->errors)) {
$return['isSaved'] = (bool) $customer->update();
} else {
$return['isSaved'] = false;
}
die(Tools::jsonEncode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if (self::$cookie->isLogged()) {
// check if customer have addresses
if (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
die(Tools::jsonEncode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) {
include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php';
$blockUserInfo = new BlockUserInfo();
}
self::$smarty->assign('isVirtualCart', self::$cart->isVirtualCart());
$this->_processAddressFormat();
$this->_assignAddress();
// Wrapping fees
$wrapping_fees = (double) Configuration::get('PS_GIFT_WRAPPING_PRICE');
$wrapping_fees_tax = new Tax((int) Configuration::get('PS_GIFT_WRAPPING_TAX'));
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (double) $wrapping_fees_tax->rate / 100);
$return = array('summary' => self::$cart->getSummaryDetails(), 'order_opc_adress' => self::$smarty->fetch(_PS_THEME_DIR_ . 'order-address.tpl'), 'block_user_info' => isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : '', 'carrier_list' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'no_address' => 0, 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) self::$cookie->id_currency))));
die(Tools::jsonEncode($return));
}
die(Tools::displayError());
break;
case 'makeFreeOrder':
/* Bypass payment step if total is 0 */
if ($id_order = $this->_checkFreeOrder() and $id_order) {
$email = self::$cookie->email;
if (self::$cookie->is_guest) {
self::$cookie->logout();
}
// If guest we clear the cookie for security reason
die('freeorder:' . $id_order . ':' . $email);
}
exit;
break;
case 'updateAddressesSelected':
//.........这里部分代码省略.........
示例15: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Customer $customer)
{
$input = array_except(Input::all(), array('_method', 'password', 'password_confirmation'));
$customer->fill($input);
$validation_rules = array_except(Customer::$validation_rules, array('password', 'password_confirmation'));
$validation_rules['email'] = $validation_rules['email'] . ',' . $customer->id;
Log::debug('customer - update - validation rule', $validation_rules);
$validator = Validator::make($input, $validation_rules);
if ($validator->passes()) {
if ($customer->update()) {
return Redirect::route('customers.show', $customer->id)->with('message', 'Customer updated.');
} else {
return Redirect::route('customers.edit', array_get($customer->getOriginal(), 'id'))->withInput()->withErrors($customer->errors());
}
} else {
return Redirect::route('customers.edit', array_get($customer->getOriginal(), 'id'))->withInput()->withErrors($validator->errors());
}
}