本文整理汇总了PHP中Purchase::notification方法的典型用法代码示例。如果您正苦于以下问题:PHP Purchase::notification方法的具体用法?PHP Purchase::notification怎么用?PHP Purchase::notification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Purchase
的用法示例。
在下文中一共展示了Purchase::notification方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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);
//.........这里部分代码省略.........