本文整理汇总了PHP中Order::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::write方法的具体用法?PHP Order::write怎么用?PHP Order::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendReceipt
/**
* Send customer an order receipt email.
* Precondition: The order payment has been successful
*/
public function sendReceipt()
{
$subject = sprintf(_t("OrderNotifier.RECEIPTSUBJECT", "Order #%d Receipt"), $this->order->Reference);
$this->sendEmail('Order_ReceiptEmail', $subject, self::config()->bcc_receipt_to_admin);
$this->order->ReceiptSent = SS_Datetime::now()->Rfc2822();
$this->order->write();
}
示例2: testSinglePageConfig
public function testSinglePageConfig()
{
ShopTest::setConfiguration();
//start a new order
$order = new Order();
$order->write();
$config = new SinglePageCheckoutComponentConfig($order);
$components = $config->getComponents();
//assertions!
$fields = $config->getFormFields();
//assertions!
$required = $config->getRequiredFields();
//assertions!
//$validateData = $config->validateData($data);
//assertions!
$data = $config->getData();
//assertions!
$config->setData($data);
//assertions!
//form field generation
//validate data
//set data
//get data
$this->markTestIncomplete('Lots missing here');
}
示例3: setData
public function setData(Order $order, array $data)
{
if (isset($data['Notes'])) {
$order->Notes = $data['Notes'];
}
//TODO: save this to an order log
$order->write();
}
示例4: createOrder
public function createOrder()
{
$order = new Order();
$order->write();
$item1a = $this->mp3player->createItem(2);
$item1a->write();
$order->Items()->add($item1a);
$item1b = $this->socks->createItem();
$item1b->write();
$order->Items()->add($item1b);
return $order;
}
示例5: Order
function old_testValidateWrongCurrency()
{
$o = new Order();
$o->Currency = 'USD';
$o->write();
$p = new Payment();
$p->Money->setCurrency('EUR');
//fails here
$p->Money->setAmount(1.23);
$p->OrderID = $o->ID;
$validationResult = $p->validate();
$this->assertContains('Currency of payment', $validationResult->message());
}
示例6: doStep
/**
* Add the member to the order, in case the member is not an admin.
*
* @param DataObject - $order Order
* @return Boolean
**/
public function doStep(Order $order)
{
if (!$order->MemberID) {
$member = Member::currentUser();
if ($member) {
if (!$member->IsShopAdmin()) {
$order->MemberID = $member->ID();
$order->write();
}
}
}
return true;
}
示例7: testGetTotalStockInCarts
public function testGetTotalStockInCarts()
{
$this->setStockFor($this->phone, 10);
$order = new Order(array('Status' => 'Cart'));
$order->write();
$orderItem = new Product_OrderItem(array('ProductID' => $this->phone->ID, 'OrderID' => $order->ID, 'Quantity' => '5'));
$orderItem->write();
$this->assertEquals(5, $this->phone->getTotalStockInCarts());
// test variations
$this->setStockFor($this->ballRedSmall, 5);
$orderItem = $orderItem->newClassInstance('ProductVariation_OrderItem');
$orderItem->ProductVariationID = $this->ballRedSmall->ID;
$orderItem->write();
$this->assertEquals(5, $this->ballRedSmall->getTotalStockInCarts());
}
示例8: Order
/**
* Get the current order from the session, if order does not exist create a new one.
*
* @return Order The current order (cart)
*/
static function get_current_order()
{
$orderID = Session::get('Cart.OrderID');
$order = null;
if ($orderID) {
$order = DataObject::get_by_id('Order', $orderID);
}
if (!$orderID || !$order || !$order->exists()) {
$order = new Order();
$order->write();
Session::set('Cart', array('OrderID' => $order->ID));
Session::save();
}
return $order;
}
示例9: testRun
public function testRun()
{
SS_Datetime::set_mock_now('2014-01-31 13:00:00');
// less than two hours old
$orderRunningRecent = new Order(array('Status' => 'Cart'));
$orderRunningRecentID = $orderRunningRecent->write();
DB::query('UPDATE "Order" SET "LastEdited" = \'2014-01-31 12:30:00\' WHERE "ID" = ' . $orderRunningRecentID);
// three hours old
$orderRunningOld = new Order(array('Status' => 'Cart'));
$orderRunningOldID = $orderRunningOld->write();
DB::query('UPDATE "Order" SET "LastEdited" = \'2014-01-31 10:00:00\' WHERE "ID" = ' . $orderRunningOldID);
// three hours old
$orderPaidOld = new Order(array('Status' => 'Paid'));
$orderPaidOldID = $orderPaidOld->write();
DB::query('UPDATE "Order" SET "LastEdited" = \'2014-01-31 10:00:00\' WHERE "ID" = ' . $orderPaidOldID);
$task = new CartCleanupTaskTest_CartCleanupTaskFake();
$response = $task->run(new SS_HTTPRequest('GET', '/'));
$this->assertInstanceOf('Order', Order::get()->byID($orderRunningRecentID));
$this->assertNull(Order::get()->byID($orderRunningOldID));
$this->assertInstanceOf('Order', Order::get()->byID($orderPaidOldID));
$this->assertEquals('1 old carts removed.', $task->log[count($task->log) - 1]);
SS_Datetime::clear_mock_now();
}
示例10: index
/**
* Action that gets called before we interface with our payment
* method.
*
* This action is responsible for setting up an order and
* saving it into the database (as well as a session) and also then
* generating an order summary before the user performs any final
* actions needed.
*
* This action is then mapped directly to the index action of the
* Handler for the payment method that was selected by the user
* in the "Postage and Payment" form.
*
*/
public function index()
{
$cart = ShoppingCart::get();
// If shopping cart doesn't exist, redirect to base
if (!$cart->getItems()->exists() || $this->getPaymentHandler() === null) {
return $this->redirect(Director::BaseURL());
}
// Get billing and delivery details and merge into an array
$billing_data = Session::get("Commerce.BillingDetailsForm.data");
$delivery_data = Session::get("Commerce.DeliveryDetailsForm.data");
$postage = PostageArea::get()->byID(Session::get('Commerce.PostageID'));
if (!$postage || !$billing_data || !$delivery_data) {
return $this->redirect(Checkout_Controller::create()->Link());
}
// Work out if an order prefix string has been set in siteconfig
$config = SiteConfig::current_site_config();
$order_prefix = $config->OrderPrefix ? $config->OrderPrefix . '-' : '';
// Merge billand and delivery data into an array
$data = array_merge((array) $billing_data, (array) $delivery_data);
// Set discount info
$data['DiscountAmount'] = $cart->DiscountAmount();
// Get postage data
$data['PostageType'] = $postage->Title;
$data['PostageCost'] = $postage->Cost;
$data['PostageTax'] = $config->TaxRate > 0 && $postage->Cost > 0 ? (double) $postage->Cost / 100 * $config->TaxRate : 0;
// Set status
$data['Status'] = 'incomplete';
// Setup an order based on the data from the shopping cart and load data
$order = new Order();
$order->update($data);
// If user logged in, track it against an order
if (Member::currentUserID()) {
$order->CustomerID = Member::currentUserID();
}
// Write so we can setup our foreign keys
$order->write();
// Loop through each session cart item and add that item to the order
foreach ($cart->getItems() as $cart_item) {
$order_item = new OrderItem();
$order_item->Title = $cart_item->Title;
$order_item->SKU = $cart_item->SKU;
$order_item->Price = $cart_item->Price;
$order_item->Tax = $cart_item->Tax;
$order_item->Customisation = serialize($cart_item->Customised);
$order_item->Quantity = $cart_item->Quantity;
$order_item->write();
$order->Items()->add($order_item);
}
$order->write();
// Add order to session so our payment handler can process it
Session::set("Commerce.Order", $order);
$this->payment_handler->setOrder($order);
// Get gateway data
$return = $this->payment_handler->index();
return $this->customise($return)->renderWith(array("Payment", "Commerce", "Page"));
}
示例11: current_order
/**
* Finds or creates a current order.
* @todo split this into two functions: initcart, and currentcart...so that templates can return null for Cart
*/
public static function current_order()
{
if (self::$order) {
return self::$order;
}
//we only want to hit the database once
//find order by id saved to session (allows logging out and retaining cart contents)
$cartid = Session::get(self::$cartid_session_name);
//TODO: make clear cart on logout optional
if ($cartid && ($o = DataObject::get_one('Order', "\"Status\" = 'Cart' AND \"ID\" = {$cartid}"))) {
$order = $o;
} else {
$order = new Order();
$order->SessionID = session_id();
if (EcommerceRole::get_associate_to_current_order()) {
$order->MemberID = Member::currentUserID();
}
// Set the Member relation to this order
$order->write();
Session::set(self::$cartid_session_name, $order->ID);
//init modifiers the first time the order is created
// (currently assumes modifiers won't change)
}
self::$order = $order;
//temp caching
$order->initModifiers();
//init /re-init modifiers
$order->write();
// Write the order
return $order;
}
示例12: changeSubscription
public function changeSubscription($data, $form)
{
//Get the record ID
$id = Controller::curr()->request->param('ID');
// Get the subscription
$subscription = Subscription::get()->byID($id);
//Get the new product ID
$newProductID = $data['ProductID'];
if ($subscription->ProductID == $newProductID) {
$form->sessionMessage("Please select a new subscription.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
// Get the Page controller
$Pg_Ctrl = new Page_Controller();
// Get InfusionSoft Api
$app = $Pg_Ctrl->getInfusionSoftApi();
// Get AttentionWizard member
$member = Member::get()->byID($data['MemberID']);
// Get IndusionSoft contact ID
$isConID = $member->ISContactID;
//Get current date
$curdate = $app->infuDate(date('j-n-Y'));
//Get old order
$oldOrder = $subscription->Order();
//Get new product
$product = Product::get()->byID($newProductID);
$credits = $product->Credits;
$isProductID = $product->ISInitialProductID;
// Get the current InfusionSoft credit card ID
$creditCard = $Pg_Ctrl->getCurrentCreditCard($member->ID);
if (!$creditCard) {
$form->sessionMessage("The user does not have a Credit Card on account, please add a credit card.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
$ccID = $creditCard->ISCCID;
$subscriptionID = $Pg_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
if ($subscriptionID && is_int($subscriptionID)) {
// Create an order
$order = new Order();
$order->OrderStatus = 'P';
$order->Amount = $product->RecurringPrice;
$order->MemberID = $member->ID;
$order->ProductID = $newProductID;
$order->CreditCardID = $creditCard->ID;
$orderID = $order->write();
//Create an infusionsoft order
$config = SiteConfig::current_site_config();
$invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
$orderItem = $app->addOrderItem($invoiceId, $isProductID, 9, floatval($product->RecurringPrice), 1, $product->Name, $product->Name);
$result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
if ($result['Successful']) {
$nextBillDate = $Pg_Ctrl->getSubscriptionNextBillDate($subscriptionID);
$expireDate = date('Y-m-d H:i:s', strtotime($nextBillDate));
$startDate = date('Y-m-d H:i:s', strtotime($expireDate . "-30 days"));
//Set the current subscription to Inactive
$Pg_Ctrl->setSubscriptionStatus($subscription->SubscriptionID, 'Inactive');
//Remove trial tag if exists
$app->grpRemove($isConID, 2216);
//get old Tag ID
if ($Pg_Ctrl->isTrialMember($member->ID)) {
$oldISTagID = 2216;
} else {
$oldISTagID = $Pg_Ctrl->getISTagIdByProduct($oldOrder->ProductID);
}
//Remove old tag ID
$app->grpRemove($isConID, $oldISTagID);
$newISTagID = $Pg_Ctrl->getISTagIdByProduct($newProductID);
//Add new tag ID
$app->grpAssign($isConID, $newISTagID);
//Add a note
$conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Payment made for AW service", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'CreationNotes' => "{$product->Name} Subscription", 'UserID' => 1);
$app->dsAdd("ContactAction", $conActionDat);
$returnFields = array('_AWofmonths');
$conData = $app->loadCon($isConID, $returnFields);
$conDat = array('_AWofmonths' => (isset($conData['_AWofmonths']) ? $conData['_AWofmonths'] : 0) + 1, '_AttentionWizard' => 'Paid and Current');
$app->updateCon($isConID, $conDat);
//Create a new Subscription
$newSubscription = new Subscription();
$newSubscription->StartDate = $startDate;
$newSubscription->ExpireDate = $expireDate;
$newSubscription->SubscriptionID = $subscriptionID;
$newSubscription->Status = 1;
$newSubscription->IsTrial = 0;
$newSubscription->SubscriptionCount = 1;
$newSubscription->MemberID = $member->ID;
$newSubscription->ProductID = $newProductID;
$newSubscription->OrderID = $orderID;
$newSubscription->write();
// Create a MemberCredits record
$memberCredits = new MemberCredits();
$memberCredits->Credits = $credits;
$memberCredits->Expire = 1;
$memberCredits->ExpireDate = $expireDate;
$memberCredits->MemberID = $member->ID;
$memberCredits->ProductID = $newProductID;
$memberCredits->SubscriptionID = $newSubscription->ID;
$memberCredits->write();
// Update order
$order->OrderStatus = 'c';
$order->write();
//.........这里部分代码省略.........
示例13: sendReceipt
/**
* Send the receipt of the order by mail.
* Precondition: The order payment has been successful
*/
public function sendReceipt()
{
$this->sendEmail('Order_ReceiptEmail', Config::inst()->get('OrderProcessor', 'bcc_receipt_to_admin'));
$this->order->ReceiptSent = SS_Datetime::now()->Rfc2822();
$this->order->write();
}
示例14: createorder
private function createorder()
{
$order = new Order();
$order->UseShippingAddress = true;
$order->CustomerOrderNote = "THIS IS AN AUTO-GENERATED ORDER";
$order->write();
$member = new Member();
$member->FirstName = 'Tom';
$member->Surname = 'Cruize';
$member->Email = 'tom@silverstripe-ecommerce.com';
$member->Password = 'test123';
$member->write();
$order->MemberID = $member->ID;
$billingAddress = new BillingAddress();
$billingAddress->Prefix = "Dr";
$billingAddress->FirstName = "Tom";
$billingAddress->Surname = "Cruize";
$billingAddress->Address = "Lamp Drive";
$billingAddress->Address2 = "Linux Mountain";
$billingAddress->City = "Apache Town";
$billingAddress->PostalCode = "555";
$billingAddress->Country = "NZ";
$billingAddress->Phone = "555 5555555";
$billingAddress->Email = "tom@silverstripe-ecommerce.com";
$billingAddress->write();
$order->BillingAddressID = $billingAddress->ID;
$shippingAddress = new ShippingAddress();
$shippingAddress->ShippingPrefix = "Dr";
$shippingAddress->ShippingFirstName = "Tom";
$shippingAddress->ShippingSurname = "Cruize";
$shippingAddress->ShippingAddress = "Lamp Drive";
$shippingAddress->ShippingAddress2 = "Linux Mountain";
$shippingAddress->ShippingCity = "Apache Town";
$shippingAddress->ShippingPostalCode = "555";
$shippingAddress->ShippingCountry = "NZ";
$shippingAddress->ShippingPhone = "555 5555555";
$shippingAddress->write();
$order->ShippingAddressID = $shippingAddress->ID;
//get a random product
$extension = "";
if (Versioned::current_stage() == "Live") {
$extension = "_Live";
}
$count = 0;
$noProductYet = true;
$triedArray = array(0 => 0);
while ($noProductYet && $count < 50) {
$product = Product::get()->where("\"ClassName\" = 'Product' AND \"Product{$extension}\".\"ID\" NOT IN (" . implode(",", $triedArray) . ") AND Price > 0")->First();
if ($product) {
if ($product->canPurchase()) {
$noProductYet = false;
} else {
$triedArray[] = $product->ID;
}
}
$count++;
}
//adding product order item
$item = new Product_OrderItem();
$item->addBuyableToOrderItem($product, 7);
$item->OrderID = $order->ID;
$item->write();
//final save
$order->write();
$order->tryToFinaliseOrder();
}
示例15: doPrepaidSignup
function doPrepaidSignup()
{
$data = $_POST;
//Check for existing member email address
if ($member = DataObject::get_one("Member", "`Email` = '" . Convert::raw2sql($data['Email']) . "'")) {
return "inlineMsg1";
}
$currentYear = date('Y');
$currentMonth = date('n');
//Stop sign-up when the credit card is expired
if ($data['ExpirationYear'] < $currentYear) {
return "inlineMsg6";
}
if ($data['ExpirationYear'] == $currentYear) {
if ($data['ExpirationMonth'] < $currentMonth) {
return "inlineMsg6";
}
}
//Get InfusionSoft Api
$app = $this->getInfusionSoftApi();
// Get country text from code
$country = Geoip::countryCode2name($data['Country']);
// Create IndusionSoft contact
$returnFields = array('Id');
$conInfo = $app->findByEmail($data['Email'], $returnFields);
if (count($conInfo)) {
$isConID = $conInfo[0]['Id'];
} else {
$conDat = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'Company' => $data['Company'], 'StreetAddress1' => $data['StreetAddress1'], 'StreetAddress2' => $data['StreetAddress2'], 'City' => $data['City'], 'State' => $data['State'], 'PostalCode' => $data['PostalCode'], 'Country' => $country, 'Email' => $data['Email']);
$isConID = $app->addCon($conDat);
}
// Locate existing credit card
$ccID = $app->locateCard($isConID, substr($data['CreditCardNumber'], -4, 4));
$creditCardType = $this->getISCreditCardType($data['CreditCardType']);
if (!$ccID) {
//Validate the credit card
$card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $data['CreditCardNumber'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear'], 'CVV2' => $data['CVVCode']);
$result = $app->validateCard($card);
if ($result['Valid'] == 'false') {
return "inlineMsg5";
}
$ccData = array('ContactId' => $isConID, 'FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CardNumber' => $data['CreditCardNumber'], 'CVV2' => $data['CVVCode'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear']);
$ccID = $app->dsAdd("CreditCard", $ccData);
}
// Create AttentionWizard member
$member = new Member();
$member->FirstName = $data['FirstName'];
$member->Surname = $data['LastName'];
$member->Email = $data['Email'];
$member->Password = $data['Password']['_Password'];
$member->ISContactID = $isConID;
$memberID = $member->write();
//Find or create the 'user' group
if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
$userGroup = new Group();
$userGroup->Code = "customers";
$userGroup->Title = "Customers";
$userGroup->Write();
}
//Add member to user group
$userGroup->Members()->add($member);
//Get the current date
$curdate = $app->infuDate(date('j-n-Y'));
$product = Product::get()->byID(7);
// Store credit card info
$creditCard = new CreditCard();
$creditCard->CreditCardType = $data['CreditCardType'];
$creditCard->CreditCardNumber = $data['CreditCardNumber'];
$creditCard->NameOnCard = $data['NameOnCard'];
$creditCard->CreditCardCVV = $data['CVVCode'];
$creditCard->ExpiryMonth = $data['ExpirationMonth'];
$creditCard->ExpiryYear = $data['ExpirationYear'];
$creditCard->Company = $data['Company'];
$creditCard->StreetAddress1 = $data['StreetAddress1'];
$creditCard->StreetAddress2 = $data['StreetAddress2'];
$creditCard->City = $data['City'];
$creditCard->State = $data['State'];
$creditCard->PostalCode = $data['PostalCode'];
$creditCard->Country = $data['Country'];
$creditCard->Current = 1;
$creditCard->ISCCID = $ccID;
$creditCard->MemberID = $memberID;
$creditCardID = $creditCard->write();
// Create an Infusionsoft order
$config = SiteConfig::current_site_config();
$invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
$orderItem = $app->addOrderItem($invoiceId, $this->getNonExpiringIsProductId(7), 3, floatval($data['Price']), intval($data['Quantity']), $product->Name, $product->Name);
$result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
// Create an order
$order = new Order();
$order->OrderStatus = 'P';
$order->Amount = $data['Price'] * $data['Quantity'];
$order->MemberID = $memberID;
$order->ProductID = 7;
$order->CreditCardID = $creditCardID;
$orderID = $order->write();
$returnFields = array('_AttentionWizard', 'Leadsource');
$conDat1 = $app->loadCon($isConID, $returnFields);
if ($result['Successful']) {
// Add tag Paid member - prepaid
//.........这里部分代码省略.........