本文整理汇总了PHP中Purchase::copydata方法的典型用法代码示例。如果您正苦于以下问题:PHP Purchase::copydata方法的具体用法?PHP Purchase::copydata怎么用?PHP Purchase::copydata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Purchase
的用法示例。
在下文中一共展示了Purchase::copydata方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purchase
/**
* Generates a Purchase record from the order
*
* @since 1.1
*
* @return void
**/
function purchase () {
global $Ecart;
// Need a transaction ID to create a purchase
if (empty($this->txnid)) return false;
// Lock for concurrency protection
$this->lock();
$Purchase = new Purchase($this->txnid,'txnid');
if (!empty($Purchase->id)) {
$this->unlock();
$Ecart->resession();
$this->purchase = $Purchase->id;
if ($this->purchase !== false)
ecart_redirect(ecarturl(false,'thanks'));
}
// WordPress account integration used, customer has no wp user
if ("wordpress" == $this->accounts && empty($this->Customer->wpuser)) {
if ( $wpuser = get_current_user_id() ) $this->Customer->wpuser = $wpuser; // use logged in WordPress account
else $this->Customer->create_wpuser(); // not logged in, create new account
}
// New customer, save hashed password
if (!$this->Customer->exists() && !empty($this->Customer->password)) {
$this->Customer->id = false;
if (ECART_DEBUG) new EcartError('Creating new Ecart customer record','new_customer',ECART_DEBUG_ERR);
if ("ecart" == $this->accounts) $this->Customer->notification();
$this->Customer->password = wp_hash_password($this->Customer->password);
} else unset($this->Customer->password); // Existing customer, do not overwrite password field!
$this->Customer->save();
$this->Billing->customer = $this->Customer->id;
$this->Billing->card = substr($this->Billing->card,-4);
$paycard = Lookup::paycard($this->Billing->cardtype);
$this->Billing->cardtype = !$paycard?$this->Billing->cardtype:$paycard->name;
$this->Billing->cvv = false;
$this->Billing->save();
// Card data is truncated, switch the cart to normal mode
$Ecart->Shopping->secured(false);
if (!empty($this->Shipping->address)) {
$this->Shipping->customer = $this->Customer->id;
$this->Shipping->save();
}
$base = $Ecart->Settings->get('base_operations');
$promos = array();
foreach ($this->Cart->discounts as &$promo) {
$promos[$promo->id] = $promo->name;
$promo->uses++;
}
$Purchase = new Purchase();
$Purchase->copydata($this);
$Purchase->copydata($this->Customer);
$Purchase->copydata($this->Billing);
$Purchase->copydata($this->Shipping,'ship');
$Purchase->copydata($this->Cart->Totals);
$Purchase->customer = $this->Customer->id;
$Purchase->billing = $this->Billing->id;
$Purchase->shipping = $this->Shipping->id;
$Purchase->taxing = ($base['vat'])?'inclusive':'exclusive';
$Purchase->promos = $promos;
$Purchase->freight = $this->Cart->Totals->shipping;
$Purchase->ip = $Ecart->Shopping->ip;
$Purchase->save();
$this->unlock();
Promotion::used(array_keys($promos));
foreach($this->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->price = $Item->option->id;
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) $Purchased->keygen();
$Purchased->save();
if ($Item->inventory) $Item->unstock();
}
$this->purchase = $Purchase->id;
$Ecart->Purchase = &$Purchase;
if (ECART_DEBUG) new EcartError('Purchase '.$Purchase->id.' was successfully saved to the database.',false,ECART_DEBUG_ERR);
do_action('ecart_order_notifications');
//.........这里部分代码省略.........
示例2: order
//.........这里部分代码省略.........
if (SHOPP_DEBUG) {
new ShoppError('Creating a new WordPress account for this customer.', false, SHOPP_DEBUG_ERR);
}
if (!$Order->Customer->new_wpuser()) {
new ShoppError(__('Account creation failed on order for customer id:' . $Order->Customer->id, "Shopp"), false, SHOPP_TRXN_ERR);
}
}
}
// Create a WP-compatible password hash to go in the db
if (empty($Order->Customer->id)) {
$Order->Customer->password = wp_hash_password($Order->Customer->password);
}
$Order->Customer->save();
$Order->Billing->customer = $Order->Customer->id;
$Order->Billing->card = substr($Order->Billing->card, -4);
$Order->Billing->save();
// Card data is truncated, switch the cart to normal mode
if ($Shopp->Cart->secured() && is_shopp_secure()) {
$Shopp->Cart->secured(false);
}
if (!empty($Order->Shipping->address)) {
$Order->Shipping->customer = $Order->Customer->id;
$Order->Shipping->save();
}
$Promos = array();
foreach ($Shopp->Cart->data->PromosApplied as $promo) {
$Promos[$promo->id] = $promo->name;
}
if ($Shopp->Cart->orderisfree()) {
$orderisfree = true;
} else {
$orderisfree = false;
}
$Purchase = new Purchase();
$Purchase->customer = $Order->Customer->id;
$Purchase->billing = $Order->Billing->id;
$Purchase->shipping = $Order->Shipping->id;
$Purchase->copydata($Order->Customer);
$Purchase->copydata($Order->Billing);
$Purchase->copydata($Order->Shipping, 'ship');
$Purchase->copydata($Shopp->Cart->data->Totals);
$Purchase->data = $Order->data;
$Purchase->promos = $Promos;
$Purchase->freight = $Shopp->Cart->data->Totals->shipping;
$Purchase->gateway = $gatewayname;
$Purchase->transactionid = $transactionid;
$Purchase->transtatus = "CHARGED";
$Purchase->ip = $Shopp->Cart->ip;
$Purchase->save();
// echo "<pre>"; print_r($Purchase); echo "</pre>";
foreach ($Shopp->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
if (SHOPP_DEBUG) {
new ShoppError('Purchase ' . $Purchase->id . ' was successfully saved to the database.', false, SHOPP_DEBUG_ERR);
}
}
// Skip post order if no Purchase ID exists
if (empty($Purchase->id)) {
return true;
}
// Empty cart on successful order
$Shopp->Cart->unload();
session_destroy();
// Start new cart session
$Shopp->Cart = new Cart();
session_start();
// Keep the user logged in or log them in if they are a new customer
if ($Shopp->Cart->data->login || $authentication != "none") {
$Shopp->Cart->loggedin($Order->Customer);
}
// Save the purchase ID for later lookup
$Shopp->Cart->data->Purchase = new Purchase($Purchase->id);
$Shopp->Cart->data->Purchase->load_purchased();
// // $Shopp->Cart->save();
// Allow other WordPress plugins access to Purchase data to extend
// what Shopp does after a successful transaction
do_action_ref_array('shopp_order_success', array(&$Shopp->Cart->data->Purchase));
// Send email notifications
// notification(addressee name, email, subject, email template, receipt template)
$Purchase->notification("{$Purchase->firstname} {$Purchase->lastname}", $Purchase->email, __('Order Receipt', 'Shopp'));
if ($Shopp->Settings->get('receipt_copy') == 1) {
$Purchase->notification('', $Shopp->Settings->get('merchant_email'), __('New Order', 'Shopp'));
}
$ssl = true;
// Test Mode will not require encrypted checkout
if (strpos($gateway, "TestMode.php") !== false || isset($_GET['shopp_xco']) || $orderisfree || SHOPP_NOSSL) {
$ssl = false;
}
shopp_redirect($Shopp->link('receipt', $ssl));
}
示例3: process
function process()
{
global $Shopp;
if (empty($_POST)) {
new ShoppError(__('Payment could not be confirmed, this order cannot be processed.', 'Shopp'), '2co_transaction_error', SHOPP_COMM_ERR);
exit;
}
session_unset();
session_destroy();
// Load the cart for the correct order
$Shopp->Cart = new Cart();
$Shopp->Cart->session = $_POST['vendor_order_id'];
session_start();
$Shopp->Cart->load($Shopp->Cart->session);
if ($this->settings['verify'] == "on" && !$this->validate($_POST['key'])) {
new ShoppError(__('The order submitted to 2Checkout could not be verified.', 'Shopp'), '2co_validation_error', SHOPP_TRXN_ERR);
exit;
}
if ($_POST['credit_card_processed'] == "N") {
new ShoppError(__('The payment failed. Please try your order again with a different payment method.', 'Shopp'), '2co_processing_error', SHOPP_TRXN_ERR);
exit;
}
if (!$Shopp->Cart->validorder()) {
new ShoppError(__('There is not enough customer information to process the order.', 'Shopp'), 'invalid_order', SHOPP_TRXN_ERR);
exit;
}
$Order = $Shopp->Cart->data->Order;
$Order->Totals = $Shopp->Cart->data->Totals;
$Order->Items = $Shopp->Cart->contents;
$Order->Cart = $Shopp->Cart->session;
$Order->Customer->save();
$Order->Billing->customer = $Order->Customer->id;
$Order->Billing->cardtype = "2Checkout";
$Order->Billing->save();
$Order->Shipping->customer = $Order->Customer->id;
$Order->Shipping->save();
$Purchase = new Purchase();
$Purchase->customer = $Order->Customer->id;
$Purchase->billing = $Order->Billing->id;
$Purchase->shipping = $Order->Shipping->id;
$Purchase->copydata($Order->Customer);
$Purchase->copydata($Order->Billing);
$Purchase->copydata($Order->Shipping, 'ship');
$Purchase->copydata($Order->Totals);
$Purchase->freight = $Order->Totals->shipping;
$Purchase->gateway = "2Checkout";
$Purchase->transtatus = "CHARGED";
$Purchase->transactionid = $_POST['order_number'];
$Purchase->ip = $Shopp->Cart->ip;
$Purchase->save();
foreach ($Shopp->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
return $Purchase;
}
示例4: order
/**
* order()
* Handles new order notifications from Google */
function order($XML)
{
global $Shopp;
$db = DB::get();
// Check if this is a Shopp order or not
$origin = $XML->getElementContent('shopping-cart-agent');
if (empty($origin) || substr($origin, 0, strpos("/", SHOPP_GATEWAY_USERAGENT)) == SHOPP_GATEWAY_USERAGENT) {
return true;
}
$buyer = $XML->getElement('buyer-billing-address');
$buyer = $buyer['CHILDREN'];
$Customer = new Customer();
$name = $XML->getElement('structured-name');
$Customer->firstname = $buyer['structured-name']['CHILDREN']['first-name']['CONTENT'];
$Customer->lastname = $buyer['structured-name']['CHILDREN']['last-name']['CONTENT'];
if (empty($name)) {
$name = $buyer['contact-name']['CONTENT'];
$names = explode(" ", $name);
$Customer->firstname = $names[0];
$Customer->lastname = $names[count($names) - 1];
}
$Customer->email = $buyer['email']['CONTENT'];
$Customer->phone = $buyer['phone']['CONTENT'];
$Customer->save();
$Billing = new Billing();
$Billing->customer = $Customer->id;
$Billing->address = $buyer['address1']['CONTENT'];
$Billing->xaddress = $buyer['address2']['CONTENT'];
$Billing->city = $buyer['city']['CONTENT'];
$Billing->state = $buyer['region']['CONTENT'];
$Billing->country = $buyer['country-code']['CONTENT'];
$Billing->postcode = $buyer['postal-code']['CONTENT'];
$Billing->save();
$shipto = $XML->getElement('buyer-shipping-address');
$shipto = $shipto['CHILDREN'];
$Shipping = new Shipping();
$Shipping->customer = $Customer->id;
$Shipping->address = $shipto['address1']['CONTENT'];
$Shipping->xaddress = $shipto['address2']['CONTENT'];
$Shipping->city = $shipto['city']['CONTENT'];
$Shipping->state = $shipto['region']['CONTENT'];
$Shipping->country = $shipto['country-code']['CONTENT'];
$Shipping->postcode = $shipto['postal-code']['CONTENT'];
$Shipping->save();
$Purchase = new Purchase();
$Purchase->customer = $Customer->id;
$Purchase->billing = $Billing->id;
$Purchase->shipping = $Shipping->id;
$Purchase->copydata($Customer);
$Purchase->copydata($Billing);
$Purchase->copydata($Shipping, 'ship');
$Purchase->freight = $XML->getElementContent('shipping-cost');
$Purchase->tax = $XML->getElementContent('total-tax');
$Purchase->total = $XML->getElementContent('order-total');
$Purchase->subtotal = $Purchase->total - $Purchase->frieght - $Purchase->tax;
$Purchase->gateway = "Google Checkout";
$Purchase->transactionid = $XML->getElementContent('google-order-number');
$Purchase->transtatus = $XML->getElementContent('financial-order-state');
$Purchase->ip = $XML->getElementContent('customer-ip');
$orderdata = $XML->getElement('shopp-order-data');
$data = array();
if (is_array($orderdata) && count($orderdata) > 0) {
foreach ($orderdata as $input) {
$data[$input['ATTRS']['name']] = $input['CONTENT'];
}
}
$Purchase->data = $data;
$Purchase->save();
$items = $XML->getElement('item');
if (key($items) === "CHILDREN") {
$items = array($items);
}
foreach ($items as $item) {
$xml = $item['CHILDREN'];
$itemdata = $xml['merchant-private-item-data']['CHILDREN'];
$inputdata = $itemdata['shopp-item-data-list']['CHILDREN']['shopp-item-data'];
$data = array();
if (is_array($inputdata) && count($inputdata) > 0) {
foreach ($inputdata as $input) {
$data[$input['ATTRS']['name']] = $input['CONTENT'];
}
}
$Product = new Product($itemdata['shopp-product-id']['CONTENT']);
$Item = new Item($Product, $itemdata['shopp-price-id']['CONTENT'], false, $data);
$Item->quantity($xml['quantity']['CONTENT']);
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
}
示例5: process
function process()
{
global $Shopp;
if (!isset($Shopp->Cart->data->PayPalExpress->token) && !isset($Shopp->Cart->data->PayPalExpress->payerid)) {
return false;
}
$_ = $this->headers();
$_['METHOD'] = "DoExpressCheckoutPayment";
$_['PAYMENTACTION'] = "Sale";
$_['TOKEN'] = $Shopp->Cart->data->PayPalExpress->token;
$_['PAYERID'] = $Shopp->Cart->data->PayPalExpress->payerid;
// Transaction
$_ = array_merge($_, $this->purchase());
$this->transaction = $this->encode($_);
$result = $this->send();
if (!$result) {
new ShoppError(__('No response was received from PayPal. The order cannot be processed.', 'Shopp'), 'paypalexpress_noresults', SHOPP_COMM_ERR);
}
if (!$Shopp->Cart->validorder()) {
new ShoppError(__('There is not enough customer information to process the order.', 'Shopp'), 'invalid_order', SHOPP_TRXN_ERR);
return false;
}
// If the transaction is a success, get the transaction details,
// build the purchase receipt, save it and return it
if (strtolower($result->ack) == "success") {
$_ = $this->headers();
$_['METHOD'] = "GetTransactionDetails";
$_['TRANSACTIONID'] = $this->Response->transactionid;
$this->transaction = $this->encode($_);
$result = $this->send();
if (!$result) {
new ShoppError(__('Details for the order were not provided by PayPal.', 'Shopp'), 'paypalexpress_notrxn_details', SHOPP_COMM_ERR);
return false;
}
$Order = $Shopp->Cart->data->Order;
$Order->Totals = $Shopp->Cart->data->Totals;
$Order->Items = $Shopp->Cart->contents;
$Order->Cart = $Shopp->Cart->session;
$authentication = $Shopp->Settings->get('account_system');
if ($authentication == "wordpress") {
// Check if they've logged in
// If the shopper is already logged-in, save their updated customer info
if ($Shopp->Cart->data->login) {
if (SHOPP_DEBUG) {
new ShoppError('Customer logged in, linking Shopp customer account to existing WordPress account.', false, SHOPP_DEBUG_ERR);
}
get_currentuserinfo();
global $user_ID;
$Order->Customer->wpuser = $user_ID;
}
// Create WordPress account (if necessary)
if (!$Order->Customer->wpuser) {
if (SHOPP_DEBUG) {
new ShoppError('Creating a new WordPress account for this customer.', false, SHOPP_DEBUG_ERR);
}
if (!$Order->Customer->new_wpuser()) {
new ShoppError(__('Account creation failed on order for customer id:' . $Order->Customer->id, "Shopp"), false, SHOPP_TRXN_ERR);
}
}
}
// Create a WP-compatible password hash to go in the db
if (empty($Order->Customer->id)) {
$Order->Customer->password = wp_hash_password($Order->Customer->password);
}
$Order->Customer->save();
$Order->Billing->customer = $Order->Customer->id;
$Order->Billing->cardtype = "PayPal";
$Order->Billing->save();
$Order->Shipping->customer = $Order->Customer->id;
$Order->Shipping->save();
$Purchase = new Purchase();
$Purchase->customer = $Order->Customer->id;
$Purchase->billing = $Order->Billing->id;
$Purchase->shipping = $Order->Shipping->id;
$Purchase->copydata($Order->Customer);
$Purchase->copydata($Order->Billing);
$Purchase->copydata($Order->Shipping, 'ship');
$Purchase->copydata($Order->Totals);
$Purchase->freight = $Order->Totals->shipping;
$Purchase->gateway = "PayPal Express";
$Purchase->transactionid = $this->Response->transactionid;
$Purchase->transtatus = $this->status[$this->Response->paymentstatus];
$Purchase->ip = $Shopp->Cart->ip;
$Purchase->fees = $this->Response->feeamt;
$Purchase->save();
foreach ($Shopp->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
return $Purchase;
}
// Fail by default
//.........这里部分代码省略.........
示例6: order
function order()
{
global $Shopp;
$txnstatus = false;
$ipnstatus = $this->verifyipn();
// Validate the order notification
if ($ipnstatus != "VERIFIED") {
$txnstatus = $ipnstatus;
new ShoppError('An unverifiable order notification was received from PayPal. Possible fraudulent order attempt! The order will be created, but the order payment status must be manually set to "Charged" when the payment can be verified.', 'paypal_txn_verification', SHOPP_TRXN_ERR);
}
if (!$txnstatus) {
$txnstatus = $this->status[$_POST['payment_status']];
}
$Order = $Shopp->Cart->data->Order;
$Order->Totals = $Shopp->Cart->data->Totals;
$Order->Items = $Shopp->Cart->contents;
$Order->Cart = $Shopp->Cart->session;
if (SHOPP_DEBUG) {
new ShoppError('IPN notification validated.', false, SHOPP_DEBUG_ERR);
}
// Transaction successful, save the order
$authentication = $Shopp->Settings->get('account_system');
if ($authentication == "wordpress") {
// Check if they've logged in
// If the shopper is already logged-in, save their updated customer info
if ($Shopp->Cart->data->login) {
$user = get_userdata($Order->Customer->wpuser);
$Order->Customer->wpuser = $user->ID;
if (SHOPP_DEBUG) {
new ShoppError('Customer logged in, linking Shopp customer account to existing WordPress account.', false, SHOPP_DEBUG_ERR);
}
}
// Create WordPress account (if necessary)
if (!$Order->Customer->wpuser) {
if (SHOPP_DEBUG) {
new ShoppError('Creating a new WordPress account for this customer.', false, SHOPP_DEBUG_ERR);
}
if (!$Order->Customer->new_wpuser()) {
new ShoppError(__('Account creation failed on order for customer id:' . $Order->Customer->id, "Shopp"), false, SHOPP_TRXN_ERR);
}
}
}
// Create a WP-compatible password hash to go in the db
if (empty($Order->Customer->id) && isset($Order->Customer->password)) {
$Order->Customer->password = wp_hash_password($Order->Customer->password);
}
$Order->Customer->save();
$Order->Billing->customer = $Order->Customer->id;
$Order->Billing->cardtype = "PayPal";
$Order->Billing->save();
if (!empty($Order->Shipping->address)) {
$Order->Shipping->customer = $Order->Customer->id;
$Order->Shipping->save();
}
$Promos = array();
foreach ($Shopp->Cart->data->PromosApplied as $promo) {
$Promos[$promo->id] = $promo->name;
}
$Purchase = new Purchase();
$Purchase->customer = $Order->Customer->id;
$Purchase->billing = $Order->Billing->id;
$Purchase->shipping = $Order->Shipping->id;
$Purchase->data = $Order->data;
$Purchase->promos = $Promos;
$Purchase->copydata($Order->Customer);
$Purchase->copydata($Order->Billing);
$Purchase->copydata($Order->Shipping, 'ship');
$Purchase->copydata($Shopp->Cart->data->Totals);
$Purchase->freight = $Shopp->Cart->data->Totals->shipping;
$Purchase->gateway = "PayPal" . (isset($_POST['test_ipn']) && $_POST['test_ipn'] == "1" ? " Sandbox" : "");
$Purchase->transactionid = $_POST['txn_id'];
$Purchase->transtatus = $txnstatus;
$Purchase->fees = $_POST['mc_fee'];
$Purchase->ip = $Shopp->Cart->ip;
$Purchase->save();
// echo "<pre>"; print_r($Purchase); echo "</pre>";
foreach ($Shopp->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
// Empty cart on successful order
$Shopp->Cart->unload();
session_destroy();
// Start new cart session
$Shopp->Cart = new Cart();
session_start();
// Keep the user loggedin
if ($Shopp->Cart->data->login) {
$Shopp->Cart->loggedin($Order->Customer);
}
// Save the purchase ID for later lookup
$Shopp->Cart->data->Purchase = new Purchase($Purchase->id);
//.........这里部分代码省略.........