本文整理汇总了PHP中Customer::currentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::currentUser方法的具体用法?PHP Customer::currentUser怎么用?PHP Customer::currentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::currentUser方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePopulateFields
public function updatePopulateFields(&$data)
{
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$shippingAddress = $member->ShippingAddress();
$shippingAddressData = $shippingAddress && $shippingAddress->exists() ? array('ShippingStreakPhone' => $shippingAddress->StreakPhone, 'ShippingStreakMobile' => $shippingAddress->StreakMobile) : array();
$billingAddress = $member->BillingAddress();
$billingAddressData = $billingAddress && $billingAddress->exists() ? array('BillingStreakPhone' => $billingAddress->StreakPhone, 'BillingStreakMobile' => $billingAddress->StreakMobile) : array();
$data = array_merge($data, $shippingAddressData, $billingAddressData);
}
示例2: update
public function update(SS_HTTPRequest $request)
{
$member = Customer::currentUser();
if (!$member->canEdit()) {
return $this()->httpError(401);
}
$updateData = $request->postVars();
$updateData = ProfiledMemberForm::update_models('update', $updateData, $member);
$member->write();
/** @noinspection PhpParamsInspection */
ProfiledMemberForm::set_form_message("ProfileUpdated", CrackerjackForm::Good);
$this->sendEmail('Update', $member, $updateData);
return $this()->redirectBack();
}
示例3: repay
function repay($request)
{
Requirements::css('swipestripe/css/Shop.css');
if ($orderID = $request->param('ID')) {
$member = Customer::currentUser();
$order = Order::get()->where("\"Order\".\"ID\" = " . Convert::raw2sql($orderID))->First();
if (!$order || !$order->exists()) {
return $this->httpError(403, _t('AccountPage.NO_ORDER_EXISTS', 'Order does not exist.'));
}
if (!$order->canView($member)) {
return $this->httpError(403, _t('AccountPage.CANNOT_VIEW_ORDER', 'You cannot view orders that do not belong to you.'));
}
Session::set('Repay', array('OrderID' => $order->ID));
Session::save();
return array('Order' => $order, 'RepayForm' => $this->RepayForm());
} else {
return $this->httpError(403, _t('AccountPage.NO_ORDER_EXISTS', 'Order does not exist.'));
}
}
示例4: updatePopulateFields
public function updatePopulateFields(&$data)
{
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$shippingAddress = $member->ShippingAddress();
$shippingAddressData = $shippingAddress && $shippingAddress->exists() ? $shippingAddress->getCheckoutFormData() : array();
unset($shippingAddressData['ShippingRegionCode']);
//Not available billing address option
$billingAddress = $member->BillingAddress();
$billingAddressData = $billingAddress && $billingAddress->exists() ? $billingAddress->getCheckoutFormData() : array();
//If billing address is a subset of shipping address, consider them equal
$intersect = array_intersect(array_values($shippingAddressData), array_values($billingAddressData));
if (array_values($intersect) == array_values($billingAddressData)) {
$billingAddressData['BillToShippingAddress'] = true;
}
$data = array_merge($data, $shippingAddressData, $billingAddressData);
}
示例5: updateOrderFormCart
/**
* Update the order form cart, called via AJAX with current order form data.
* Renders the cart and sends that back for displaying on the order form page.
*
* @param SS_HTTPRequest $data Form data sent via AJAX POST.
* @return String Rendered cart for the order form, template include 'CheckoutFormOrder'.
*/
function updateOrderFormCart(SS_HTTPRequest $data)
{
if ($data->isPOST()) {
$fields = array();
$validator = new OrderFormValidator();
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$order = CartControllerExtension::get_current_order();
//Update the Order
$order->addAddressesAtCheckout($data->postVars());
$order->addModifiersAtCheckout($data->postVars());
//TODO update personal details, notes and payment type?
//Create the part of the form that displays the Order
$this->addItemFields($fields, $validator, $order);
$this->addModifierFields($fields, $validator, $order);
//This is going to go through and add modifiers based on current Form DATA
//TODO This should be constructed for non-dropdown fields as well
//Update modifier form fields so that the dropdown values are correct
$newModifierData = array();
$subTotalModifiers = isset($fields['SubTotalModifiers']) ? $fields['SubTotalModifiers'] : array();
$totalModifiers = isset($fields['Modifiers']) ? $fields['Modifiers'] : array();
$modifierFields = array_merge($subTotalModifiers, $totalModifiers);
foreach ($modifierFields as $field) {
if (method_exists($field, 'updateValue')) {
$field->updateValue($order);
}
$modifierClassName = get_class($field->getModifier());
$newModifierData['Modifiers'][$modifierClassName] = $field->Value();
}
//Add modifiers to the order again so that the new values are used
$order->addModifiersAtCheckout($newModifierData);
$actions = new FieldSet(new FormAction('ProcessOrder', _t('CheckoutPage.PROCEED_TO_PAY', "Proceed to pay")));
$form = new CheckoutForm($this, 'OrderForm', $fields, $actions, $validator, $order);
$form->disableSecurityToken();
$form->validate();
return $form->renderWith('CheckoutFormOrder');
}
}
示例6: newPaymentSuccess
/**
* newPaymentSuccess
* A payment has been made. Make the database adjustments for this gateway (if applicable).
*
* @param SS_HTTPRequest $request The GET/POST variables and URL parameters.
* @return HTMLText
*/
public function newPaymentSuccess($request)
{
/* Show customer a success screen. Back office is handled via the IPN. */
return Store_OrderController::create()->customise(array("Title" => "Thanks for your payment", "OrderNo" => $request->postVar("custom"), "Customer" => Customer::currentUser(), "Transaction" => array("ID" => $request->postVar("txn_id"), "Amount" => DataObject::get_one("StoreCurrency", "(`SystemCreated`='1')")->Symbol . $request->postVar("mc_gross"))))->renderWith(array("Store_Order_Payment_PayPal_Success", "Page"));
}
示例7: populateFields
function populateFields()
{
//Populate values in the form the first time
if (!Session::get("FormInfo.{$this->FormName()}.errors")) {
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$data = array_merge($member->toMap());
$this->extend('updatePopulateFields', $data);
$this->loadDataFrom($data);
}
}
示例8: testAddProductToCartLoggedInCustomer
/**
* Add a product logged in as a customer
*/
public function testAddProductToCartLoggedInCustomer()
{
$productA = $this->objFromFixture('Product', 'productA');
$this->logInAs('admin');
$productA->doPublish();
$this->logOut();
$this->logInAs($this->objFromFixture('Customer', 'buyer'));
$buyer = $this->objFromFixture('Customer', 'buyer');
$loggedInAs = $this->session()->get('loggedInAs');
$this->assertEquals($buyer->ID, $loggedInAs);
$member = Customer::currentUser();
$this->assertEquals(true, $member->inGroup('customers'));
$productALink = $productA->Link();
$this->get(Director::makeRelative($productALink));
$this->submitForm('ProductForm_ProductForm', null, array('Quantity' => 1));
$order = Cart::get_current_order();
$this->assertEquals(1, $order->Items()->Count());
}
示例9: place
/**
* CONTROLLER ACTION /place
* Start the order process using the current basket.
*/
public function place(SS_HTTPRequest $request)
{
/**
* If the basket is empty there is no order to process,
* so redirect the user to their basket.
*/
if (!Store_BasketController::is_basket_full()) {
return $this->redirect(Store_BasketController::get_link());
}
/**
* If no-body is currently signed in, redirect them to the login/register forms.
*/
if (!Customer::currentUser() && $request->param("ID") !== "one") {
return $this->redirect($this->link() . "/place/one", 403);
}
/**
* If the signed in user is not part of the 'Customers' group
* then they are not permitted to make an order so render an
* order error page that informs them of such.
*/
if (Customer::currentUser()) {
if (DB::Query("\n\t\t\t\tSELECT COUNT(*) FROM group_members\n\t\t\t\tWHERE (`GroupID`='" . DataObject::get_one("Group", "(`Title`='Customers')")->ID . "' \n\t\t\t\tAND `MemberID`='" . Customer::currentUserID() . "')\n\t\t\t")->value() < 1) {
return $this->customise(array("Title" => "An unexpected error occurred."))->renderWith(array("Store_Order_Error_MemberGroup", "Page"));
}
}
/**
* If customer is signed in, but no ID is set in the URL, redirect to /two.
*/
if (Customer::currentUser() && !$request->param("ID")) {
return $this->redirect($this->link() . "/place/two", 403);
}
/**
* Use switch() on $request->param("ID") to determine
* the stage of the order process.
*/
switch ($request->param("ID")) {
/**
* ORDER PROCESS STEP ONE
* Prompt the user to login or create an account.
* If the user is already signed in, redirect to stage two.
*/
case "one":
if (!Customer::currentUser()) {
Session::set('BackURL', $this->link() . "/place/two");
return $this->customise(array("Title" => "Login/Register"))->renderWith(array("Store_Order_Step1", "Page"));
} else {
return $this->redirect($this->link() . "/place/two");
}
break;
/**
* ORDER PROCESS STEP TWO
* Prompt the user to select their billing address from their
* Customer_AddressBook. Also provide forms for the customer to complete
* should they wish to enter new address.
*/
/**
* ORDER PROCESS STEP TWO
* Prompt the user to select their billing address from their
* Customer_AddressBook. Also provide forms for the customer to complete
* should they wish to enter new address.
*/
case "two":
return $this->customise(array("Title" => "Select Billing Address"))->renderWith(array("Store_Order_Step2", "Page"));
break;
/**
* ORDER PROCESS STEP THREE
* Prompt the user to select their shipping address from their
* Customer_AddressBook. Also provide forms for the customer to complete
* should they wish to enter new address.
*/
/**
* ORDER PROCESS STEP THREE
* Prompt the user to select their shipping address from their
* Customer_AddressBook. Also provide forms for the customer to complete
* should they wish to enter new address.
*/
case "three":
return $this->customise(array("Title" => "Select Delivery Address"))->renderWith(array("Store_Order_Step3", "Page"));
break;
/**
* ORDER PROCESS STEP FOUR
* Prompt the user to select their preferred courier
* should more than one be available.
*/
/**
* ORDER PROCESS STEP FOUR
* Prompt the user to select their preferred courier
* should more than one be available.
*/
case "four":
return $this->customise(array("Title" => "Select Courier"))->renderWith(array("Store_Order_Step4", "Page"));
break;
/**
* ORDER PROCESS STEP FIVE
* Based on all of the information entered show the final order summary
* including tax with a choice of payment method.
//.........这里部分代码省略.........
示例10: addAddressesAtCheckout
/**
* Add addresses to this Order at the checkout.
*
* @param Array $data
*/
function addAddressesAtCheckout(array $data)
{
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$order = CartControllerExtension::get_current_order();
$billingCountries = Country::billing_countries();
$shippingCountries = Country::shipping_countries();
$shippingRegions = Region::shipping_regions();
//If there is a current billing and shipping address, update them, otherwise create new ones
$existingBillingAddress = $this->BillingAddress();
$existingShippingAddress = $this->ShippingAddress();
if ($existingBillingAddress && $existingBillingAddress->exists()) {
$newData = array();
if (isset($data['Billing']) && is_array($data['Billing'])) {
foreach ($data['Billing'] as $fieldName => $value) {
$newData[$fieldName] = $value;
}
}
$newData['CountryID'] = $data['Billing']['Country'];
$newData['CountryName'] = in_array($newData['CountryID'], array_keys($billingCountries)) ? $billingCountries[$newData['CountryID']] : null;
if ($member->ID) {
$newData['MemberID'] = $member->ID;
}
$existingBillingAddress->update($newData);
$existingBillingAddress->write();
} else {
$billingAddress = new Address();
$billingAddress->OrderID = $order->ID;
if ($member->ID) {
$billingAddress->MemberID = $member->ID;
}
$billingAddress->FirstName = $data['Billing']['FirstName'];
$billingAddress->Surname = $data['Billing']['Surname'];
$billingAddress->Company = $data['Billing']['Company'];
$billingAddress->Address = $data['Billing']['Address'];
$billingAddress->AddressLine2 = $data['Billing']['AddressLine2'];
$billingAddress->City = $data['Billing']['City'];
$billingAddress->PostalCode = $data['Billing']['PostalCode'];
$billingAddress->State = $data['Billing']['State'];
$billingAddress->CountryID = $data['Billing']['Country'];
$billingAddress->CountryName = in_array($data['Billing']['Country'], array_keys($billingCountries)) ? $billingCountries[$data['Billing']['Country']] : null;
$billingAddress->Type = 'Billing';
$billingAddress->write();
}
if ($existingShippingAddress && $existingShippingAddress->exists()) {
$newData = array();
if (isset($data['Shipping']) && is_array($data['Shipping'])) {
foreach ($data['Shipping'] as $fieldName => $value) {
$newData[$fieldName] = $value;
}
}
$newData['CountryID'] = $data['Shipping']['Country'];
$newData['CountryName'] = in_array($newData['CountryID'], array_keys($shippingCountries)) ? $shippingCountries[$newData['CountryID']] : null;
if (isset($newData['Region']) && isset($shippingRegions[$newData['Country']])) {
if (in_array($newData['Region'], array_keys($shippingRegions[$newData['Country']]))) {
$newData['RegionName'] = $shippingRegions[$newData['Country']][$newData['Region']];
}
} else {
$newData['RegionName'] = null;
}
if ($member->ID) {
$newData['MemberID'] = $member->ID;
}
$existingShippingAddress->update($newData);
$existingShippingAddress->write();
} else {
$shippingAddress = new Address();
$shippingAddress->OrderID = $order->ID;
if ($member->ID) {
$shippingAddress->MemberID = $member->ID;
}
$shippingAddress->FirstName = $data['Shipping']['FirstName'];
$shippingAddress->Surname = $data['Shipping']['Surname'];
$shippingAddress->Company = $data['Shipping']['Company'];
$shippingAddress->Address = $data['Shipping']['Address'];
$shippingAddress->AddressLine2 = $data['Shipping']['AddressLine2'];
$shippingAddress->City = $data['Shipping']['City'];
$shippingAddress->PostalCode = $data['Shipping']['PostalCode'];
$shippingAddress->State = $data['Shipping']['State'];
$shippingAddress->CountryID = $data['Shipping']['Country'];
$shippingAddress->Region = isset($data['Shipping']['Region']) ? $data['Shipping']['Region'] : null;
$shippingAddress->CountryName = in_array($data['Shipping']['Country'], array_keys($shippingCountries)) ? $shippingCountries[$data['Shipping']['Country']] : null;
$shippingAddress->RegionName = isset($data['Shipping']['Region']) && isset($shippingRegions[$data['Shipping']['Country']]) && in_array($data['Shipping']['Region'], array_keys($shippingRegions[$data['Shipping']['Country']])) ? $shippingRegions[$data['Shipping']['Country']][$data['Shipping']['Region']] : null;
$shippingAddress->Type = 'Shipping';
$shippingAddress->write();
}
}
示例11: OrderForm
function OrderForm()
{
$order = Cart::get_current_order();
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$form = OrderForm::create($this, 'OrderForm')->disableSecurityToken();
//Populate fields the first time form is loaded
$form->populateFields();
return $form;
}
示例12: order
/**
* Return the {@link Order} details for the current Order ID that we're viewing (ID parameter in URL).
*
* @return Array Content for displaying the page
*/
function order($request)
{
Requirements::css('swipestripe/css/Shop.css');
$memberID = Member::currentUserID();
if (!Member::currentUserID()) {
return Security::permissionFailure($this, _t('AccountPage.LOGGED_IN', "You must be logged in to view this page."));
}
if ($orderID = $request->param('ID')) {
$order = DataObject::get_one('Order', "\"Order\".\"ID\" = {$orderID}");
$member = Customer::currentUser();
if (!$member || !$member->ID) {
return Security::permissionFailure($this, _t('AccountPage.LOGGED_IN', "You must be logged in to view this page."));
}
if ($member && $member != $order->Member()) {
return Security::permissionFailure($this, _t('AccountPage.CANNOT_VIEW_ORDER', "You cannot view orders that do not belong to you."));
}
if ($order && $order->exists()) {
//Because this is the page that long payment processes direct back to, want to send
//a receipt and order notification if they have not already been sent
$order->sendReceipt();
$order->sendNotification();
return array('Order' => $order);
}
}
return array('Order' => false, 'Message' => _t('AccountPage.NO_ORDER_EXISTS', "You do not have any order corresponding to this ID."));
}