本文整理汇总了PHP中Order::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::get方法的具体用法?PHP Order::get怎么用?PHP Order::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SubmittedOrder
function SubmittedOrder()
{
$lastStatusOrder = OrderStep::get()->Last();
if ($lastStatusOrder) {
return Order::get()->Filter("StatusID", $lastStatusOrder->ID)->Sort("RAND()")->First();
}
}
示例2: saveItem
/**
* (non-PHPdoc)
* @see DetailsPageAbstract::saveItem()
*/
public function saveItem($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$task = null;
if (isset($param->CallbackParameter->id) && !($task = Task::get(trim($param->CallbackParameter->id))) instanceof Task) {
throw new Exception('Invalid Task passed in!');
}
if (!isset($param->CallbackParameter->instructions) || ($instructions = trim($param->CallbackParameter->instructions)) === '') {
throw new Exception('Instructions are required!');
}
if (!isset($param->CallbackParameter->customerId) || !($customer = Customer::get(trim($param->CallbackParameter->customerId))) instanceof Customer) {
throw new Exception('Invalid Customer Passed in!');
}
$tech = isset($param->CallbackParameter->techId) ? UserAccount::get(trim($param->CallbackParameter->techId)) : null;
$order = isset($param->CallbackParameter->orderId) ? Order::get(trim($param->CallbackParameter->orderId)) : null;
$dueDate = new UDate(trim($param->CallbackParameter->dueDate));
$status = isset($param->CallbackParameter->statusId) ? TaskStatus::get(trim($param->CallbackParameter->statusId)) : null;
if (!$task instanceof Task) {
$task = Task::create($customer, $dueDate, $instructions, $tech, $order);
} else {
$task->setCustomer($customer)->setDueDate($dueDate)->setInstructions($instructions)->setTechnician($tech)->setFromEntityId($order instanceof Order ? $order->getId() : '')->setFromEntityName($order instanceof Order ? get_class($order) : '')->setStatus($status)->save();
}
// $results['url'] = '/task/' . $task->getId() . '.html?' . $_SERVER['QUERY_STRING'];
$results['item'] = $task->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例3: BillingHistory
public function BillingHistory()
{
$billingHistory = new ArrayList();
$orders = Order::get()->filter(array('MemberID' => Member::currentUserID(), 'OrderStatus' => 'c'))->sort('Created');
foreach ($orders as $order) {
$productId = $order->ProductID;
if (($productId == 1 || $productId == 2 || $productId == 3) && $order->IsTrial == 1) {
$productDesc = 'First Month Trial';
} else {
$product = Product::get()->byID($productId);
$productDesc = $product->Name;
}
$creditCard = $order->CreditCard();
$ccNumber = 'XXXX-XXXX-XXXX-' . substr($creditCard->CreditCardNumber, -4);
$orderDetails = array('Date' => $order->Created, 'Description' => $productDesc, 'CCType' => strtoupper($creditCard->CreditCardType), 'CCNumber' => $ccNumber, 'Amount' => $order->Amount);
$billingHistory->push(new ArrayData($orderDetails));
}
$memBillHistory = MemberBillingHistory::get()->filter('MemberID', Member::currentUserID())->sort('Created');
foreach ($memBillHistory as $history) {
$creditCard = $history->CreditCard();
$ccNumber = 'XXXX-XXXX-XXXX-' . substr($creditCard->CreditCardNumber, -4);
$details = array('Date' => $history->Created, 'Description' => $history->Product()->Name, 'CCType' => strtoupper($creditCard->CreditCardType), 'CCNumber' => $ccNumber, 'Amount' => $history->Product()->RecurringPrice);
$billingHistory->push(new ArrayData($details));
}
$sortedBillingHistory = $billingHistory->sort('Date');
return $sortedBillingHistory;
}
示例4: sendEmail
/**
* Sending the email out
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*/
public function sendEmail($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) {
throw new Exception('System Error: invalid order provided!');
}
if (!isset($param->CallbackParameter->emailAddress) || ($emailAddress = trim($param->CallbackParameter->emailAddress)) === '') {
throw new Exception('System Error: invalid emaill address provided!');
}
$emailBody = '';
if (isset($param->CallbackParameter->emailBody) && ($emailBody = trim($param->CallbackParameter->emailBody)) !== '') {
$emailBody = str_replace("\n", "<br />", $emailBody);
}
$pdfFile = EntityToPDF::getPDF($order);
$asset = Asset::registerAsset($order->getOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
$type = $order->getType();
EmailSender::addEmail('sales@budgetpc.com.au', $emailAddress, 'BudgetPC ' . $type . ':' . $order->getOrderNo(), (trim($emailBody) === '' ? '' : $emailBody . "<br /><br />") . 'Please find attached ' . $type . ' (' . $order->getOrderNo() . '.pdf) from Budget PC Pty Ltd.', array($asset));
$order->addComment('An email sent to "' . $emailAddress . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
$results['item'] = $order->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例5: order
/**
* Display the currently selected order from the URL
*
*/
public function order()
{
$orderID = $this->owner->request->param("ID");
$order = Order::get()->byID($orderID);
$this->owner->customise(array("ClassName" => "AccountPage", "Order" => $order));
return $this->owner->renderWith(array("UserAccount_order", "UserAccount", "Page"));
}
示例6: export
function export()
{
$orders = Order::get()->innerJoin("Address", "\"Order\".\"ShippingAddressID\" = \"Address\".\"ID\"")->filter("SentToDispatchIT", 0)->filter("Status", Order::config()->placed_status)->filter("Address.Country", "NZ")->sort(array("Placed" => "ASC", "Created" => "ASC"));
$output = "";
if ($orders->exists()) {
foreach ($orders as $order) {
$address = $order->getShippingAddress();
$name = $address->Company;
//TODO: company
if (!$name || $name == "") {
$name = $order->Name;
}
$line = array($order->ID, $order->MemberID, $name, $address->Address, $address->AddressLine2, $address->Suburb, $address->State, $address->City, "", "0", "1", "", $address->Phone, "", $order->Fax, $order->Email, "1", "", "0", "", "0");
$output .= implode("\t", $line) . "\n";
$order->SentToDispatchIT = true;
$order->write();
}
//store output in a local file, then output the contents, or a link to the file
//name format: DDcxxxxxxx.TXT
$filename = "DDc" . uniqid() . "_" . date('YmdHis') . ".txt";
$exportpath = ASSETS_PATH . "/_dispatchitexports";
if (!is_dir($exportpath)) {
mkdir($exportpath);
}
if (file_put_contents($exportpath . "/{$filename}", $output) === false) {
$output = "failed to save file";
}
} else {
$output = "no new orders";
}
header('Content-type: text/plain');
echo $output;
die;
}
示例7: testModifierFailure
public function testModifierFailure()
{
if (!ShopTools::DBConn()->supportsTransactions()) {
$this->markTestSkipped('The Database doesn\'t support transactions.');
}
Config::inst()->update('Order', 'modifiers', array('OrderModifierTest_TestModifier'));
$order = $this->createOrder();
$order->calculate();
$order->write();
// 408 from items + 10 from modifier + 25% from tax
$this->assertEquals('522.5', $order->Total);
$amounts = array();
foreach ($order->Modifiers()->sort('Sort') as $modifier) {
$amounts[] = (string) $modifier->Amount;
}
$this->assertEquals(array('10', '104.5'), $amounts);
OrderModifierTest_TestModifier::$value = 42;
try {
// Calculate will now fail!
$order->calculate();
} catch (Exception $e) {
}
// reload order from DB
$order = Order::get()->byID($order->ID);
// Order Total should not have changed
$this->assertEquals('522.5', $order->Total);
$amounts = array();
foreach ($order->Modifiers()->sort('Sort') as $modifier) {
$amounts[] = (string) $modifier->Amount;
}
$this->assertEquals(array('10', '104.5'), $amounts, 'Modifiers aren\'t allowed to change upon failure');
}
示例8: parameterFields
public function parameterFields()
{
$fields = new FieldList();
// Check if any order exist
if (Order::get()->exists()) {
$first_order = Order::get()->sort('Created ASC')->first();
$months = array('All');
$statuses = Order::config()->statuses;
array_unshift($statuses, 'All');
for ($i = 1; $i <= 12; $i++) {
$months[] = date("F", mktime(0, 0, 0, $i + 1, 0, 0));
}
// Get the first order, then count down from current year to that
$firstyear = new SS_Datetime('FirstDate');
$firstyear->setValue($first_order->Created);
$years = array();
for ($i = date('Y'); $i >= $firstyear->Year(); $i--) {
$years[$i] = $i;
}
//Result Limit
$result_limit_options = array(0 => 'All', 50 => 50, 100 => 100, 200 => 200, 500 => 500);
$fields->push(DropdownField::create('Filter_Month', 'Filter by month', $months));
$fields->push(DropdownField::create('Filter_Year', 'Filter by year', $years));
$fields->push(DropdownField::create('Filter_Status', 'Filter By Status', $statuses));
$fields->push(DropdownField::create("ResultsLimit", "Limit results to", $result_limit_options));
}
return $fields;
}
示例9: testOffsitePaymentWithGatewayCallback
public function testOffsitePaymentWithGatewayCallback()
{
//set up cart
$cart = ShoppingCart::singleton()->setCurrent($this->objFromFixture("Order", "cart"))->current();
//collect checkout details
$cart->update(array('FirstName' => 'Foo', 'Surname' => 'Bar', 'Email' => 'foo@bar.com'));
$cart->write();
//pay for order with external gateway
$processor = OrderProcessor::create($cart);
$this->setMockHttpResponse('PaymentExpress/Mock/PxPayPurchaseSuccess.txt');
$response = $processor->makePayment("PaymentExpress_PxPay", array());
//gateway responds (in a different session)
$oldsession = $this->mainSession;
$this->mainSession = new TestSession();
ShoppingCart::singleton()->clear();
$this->setMockHttpResponse('PaymentExpress/Mock/PxPayCompletePurchaseSuccess.txt');
$this->getHttpRequest()->query->replace(array('result' => 'abc123'));
$identifier = $response->getPayment()->Identifier;
$response = $this->get("paymentendpoint/{$identifier}/complete");
//reload cart as new order
$order = Order::get()->byId($cart->ID);
$this->assertFalse($order->isCart(), "order is no longer in cart");
$this->assertTrue($order->isPaid(), "order is paid");
//bring back client session
$this->mainSession = $oldsession;
$response = $this->get("paymentendpoint/{$identifier}/complete");
$this->assertNull(Session::get("shoppingcartid"), "cart session id should be removed");
$this->assertNotEquals(404, $response->getStatusCode(), "We shouldn't get page not found");
$this->markTestIncomplete("Should assert other things");
}
示例10: Orders
public function Orders()
{
if ($this->Count == 0) {
$this->Count = 10;
}
$orders = Order::get()->sort("Placed", "DESC")->exclude('Status', Config::inst()->get('DashboardRecentOrdersPanel', 'exclude_status'))->limit($this->Count);
return $orders;
}
示例11: quote
public function quote()
{
$object = Order::get()->filter(array("ClassName" => $this->config()->estimate_class, "ID" => $this->request->param("ID")))->first();
if ($object && $object->AccessKey && $object->AccessKey == $this->request->param("OtherID")) {
return $this->customise(array("SiteConfig" => SiteConfig::current_site_config(), "MetaTitle" => _t("Orders.QuoteTitle", "Quote"), "Object" => $object))->renderWith(array("OrderFront_quote", "Orders", "Page"));
} else {
return $this->httpError(404);
}
}
示例12: placeOrder
protected function placeOrder()
{
// ensure order is being reloaded from DB, to prevent dealing with stale data!
/** @var Order $order */
$order = Order::get()->byID($this->owner->OrderID);
if ($order && $order->exists()) {
OrderProcessor::create($order)->placeOrder();
}
}
示例13: run
function run($request)
{
$orders = Order::get()->where("\"Order\".\"Env\" = 'dev'");
if ($orders && $orders->exists()) {
foreach ($orders as $order) {
$order->delete();
$order->destroy();
}
}
}
示例14: allorders
/**
* Get all orders for current member / session.
* @return DataList of Orders
*/
public function allorders()
{
$filters = array('ID' => -1);
if ($sessids = self::get_session_order_ids()) {
$filters['ID'] = $sessids;
}
if ($memberid = Member::currentUserID()) {
$filters['MemberID'] = $memberid;
}
return Order::get()->filterAny($filters)->filter("Status:not", Order::config()->hidden_status);
}
示例15: orderToUse
/**
* returns the order to use.... You can provide one
* which basically just checks that it is a real order
* @param Order | Int
* @return Order
*/
protected function orderToUse($order = null)
{
if ($order && $order instanceof $order) {
return $order;
}
if (intval($order)) {
return Order::get()->byID(intval($order));
} else {
return ShoppingCart::current_order();
}
user_error("Can't find an order to use");
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:18,代码来源:EcommercePaymentSupportedMethodsProvider.php