本文整理汇总了PHP中WC_Order::reduce_order_stock方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::reduce_order_stock方法的具体用法?PHP WC_Order::reduce_order_stock怎么用?PHP WC_Order::reduce_order_stock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::reduce_order_stock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tiago_auto_stock_reduce
public function tiago_auto_stock_reduce($order_id)
{
$j = get_post_meta($order_id, '_payment_method');
if ($j[0] == 'pagseguro') {
$order = new WC_Order($order_id);
$order->reduce_order_stock();
// Payment is complete so reduce stock levels
$order->add_order_note('Estoque reduzido automaticamente ao criar pedido.');
}
}
开发者ID:TiagoSilvestre,项目名称:PluginParaBaixarEstoqueNoPedido,代码行数:10,代码来源:woocommerce-reduces-inventory-in-order.php
示例2: completeOrder
/**
* Complete a WooCommerce order
*/
public function completeOrder(WC_Order $order, $payment_hash)
{
$status = PayPro_WC_Plugin::$settings->paymentCompleteStatus();
if (empty($status)) {
$status = 'wc-processing';
}
$order->update_status($status, sprintf(__('PayPro payment succeeded (%s)', 'paypro-gateways-woocommerce'), $payment_hash));
$order->reduce_order_stock();
$order->payment_complete();
$this->removeOrderPaymentHashes($order->id);
}
示例3: process_payment
/**
* Process the payment and return the result
*
* @param int $order_id
* @return array
*/
public function process_payment($order_id)
{
$order = new WC_Order($order_id);
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', __('Awaiting cheque payment', 'woocommerce'));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
WC()->cart->empty_cart();
// Return thankyou redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}
示例4: unset
/**
* Process the payment and return the result
*
* @access public
* @param int $order_id
* @return array
*/
function process_payment($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', __('Payment to be made upon delivery.', 'woocommerce'));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$woocommerce->cart->empty_cart();
// Empty awaiting payment session
unset($_SESSION['order_awaiting_payment']);
// Return thankyou redirect
return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks')))));
}
示例5: process_pre_order
/**
* Process the pre-order.
*
* @param WC_Order $order
*
* @return array
*/
protected function process_pre_order($order_id)
{
if (WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id)) {
try {
$order = new WC_Order($order_id);
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$this->api->empty_card();
// Is pre ordered!
WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
// Return thank you page redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
} catch (Exception $e) {
$this->api->add_error('<strong>' . esc_attr($this->title) . '</strong>: ' . $e->getMessage());
return array('result' => 'fail', 'redirect' => '');
}
} else {
return parent::process_payment($order_id);
}
}
示例6: SCMerchantClient
function check_spectrocoin_callback()
{
global $woocommerce;
$ipn = $_REQUEST;
// Exit now if the $_POST was empty.
if (empty($ipn)) {
echo 'Invalid request!';
return;
}
$scMerchantClient = new SCMerchantClient(SC_API_URL, $this->get_option('merchant_id'), $this->get_option('project_id'), $this->get_option('private_key'));
$callback = $scMerchantClient->parseCreateOrderCallback($ipn);
if ($callback != null && $scMerchantClient->validateCreateOrderCallback($callback)) {
switch ($callback->getStatus()) {
case OrderStatusEnum::$New:
case OrderStatusEnum::$Pending:
break;
case OrderStatusEnum::$Expired:
case OrderStatusEnum::$Failed:
break;
case OrderStatusEnum::$Test:
case OrderStatusEnum::$Paid:
$order_number = (int) $ipn['invoice_id'];
$order = new WC_Order(absint($order_number));
$order->add_order_note(__('Callback payment completed', 'woocomerce'));
$order->payment_complete();
$order->reduce_order_stock();
break;
default:
echo 'Unknown order status: ' . $callback->getStatus();
break;
}
$woocommerce->cart->empty_cart();
echo '*ok*';
} else {
echo 'Invalid callback!';
}
exit;
}
示例7: process_pre_order
/**
* Process the pre-order
*
* @param int $order_id
* @return array
*/
public function process_pre_order($order_id)
{
if (WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id)) {
$order = new WC_Order($order_id);
// Order limit
if ($order->order_total * 100 < 50) {
$error_msg = __('Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce-payment-gateway-boilerplate');
}
if ($this->sandbox == 'yes') {
$error_msg .= ' ' . __('Developers: Please make sure that you\'re including jQuery and there are no JavaScript errors on the page.', 'woocommerce-payment-gateway-boilerplate');
}
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
WC()->cart->empty_cart();
// Is pre ordered!
WC_Pre_Orders_Order::mark_order_as_pre_ordered($order);
// Return thank you page redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
return array('result' => 'fail', 'redirect' => '');
} else {
return parent::process_payment($order_id);
}
}
开发者ID:prayas-sapkota,项目名称:WooCommerce-Payment-Gateway-Boilerplate,代码行数:30,代码来源:class-wc-gateway-payment-gateway-boilerplate-add-ons.php
示例8: process_payment
/**
* process the payment and return the result
* @param int $order_id
* @return array
*/
public function process_payment($order_id) {
global $woocommerce;
$order = new WC_Order($order_id);
$ccfields = $this->getCardFields();
$isLiveSite = ($this->eway_sandbox != 'yes');
if ($this->eway_stored == 'yes')
$eway = new EwayPaymentsStoredPayment($this->eway_customerid, $isLiveSite);
else
$eway = new EwayPaymentsPayment($this->eway_customerid, $isLiveSite);
$eway->invoiceDescription = get_bloginfo('name');
$eway->invoiceReference = $order->get_order_number(); // customer invoice reference
$eway->transactionNumber = $order_id; // transaction reference
$eway->cardHoldersName = $ccfields['eway_card_name'];
$eway->cardNumber = strtr($ccfields['eway_card_number'], array(' ' => '', '-' => ''));
$eway->cardExpiryMonth = $ccfields['eway_expiry_month'];
$eway->cardExpiryYear = $ccfields['eway_expiry_year'];
$eway->cardVerificationNumber = $ccfields['eway_cvn'];
$eway->firstName = $order->billing_first_name;
$eway->lastName = $order->billing_last_name;
$eway->emailAddress = $order->billing_email;
$eway->postcode = $order->billing_postcode;
// for Beagle (free) security
if ($this->eway_beagle == 'yes') {
$eway->customerCountryCode = $order->billing_country;
}
// convert WooCommerce country code into country name
$billing_country = $order->billing_country;
if (isset($woocommerce->countries->countries[$billing_country])) {
$billing_country = $woocommerce->countries->countries[$billing_country];
}
// aggregate street, city, state, country into a single string
$parts = array (
$order->billing_address_1,
$order->billing_address_2,
$order->billing_city,
$order->billing_state,
$billing_country,
);
$eway->address = implode(', ', array_filter($parts, 'strlen'));
// use cardholder name for last name if no customer name entered
if (empty($eway->firstName) && empty($eway->lastName)) {
$eway->lastName = $eway->cardHoldersName;
}
// allow plugins/themes to modify invoice description and reference, and set option fields
$eway->invoiceDescription = apply_filters('woocommerce_eway_invoice_desc', $eway->invoiceDescription, $order_id);
$eway->invoiceReference = apply_filters('woocommerce_eway_invoice_ref', $eway->invoiceReference, $order_id);
$eway->option1 = apply_filters('woocommerce_eway_option1', '', $order_id);
$eway->option2 = apply_filters('woocommerce_eway_option2', '', $order_id);
$eway->option3 = apply_filters('woocommerce_eway_option3', '', $order_id);
// if live, pass through amount exactly, but if using test site, round up to whole dollars or eWAY will fail
$total = $order->order_total;
$eway->amount = $isLiveSite ? $total : ceil($total);
try {
$response = $eway->processPayment();
if ($response->status) {
// transaction was successful, so record details and complete payment
update_post_meta($order_id, 'Transaction ID', $response->transactionNumber);
if (!empty($response->authCode)) {
update_post_meta($order_id, 'Authcode', $response->authCode);
}
if (!empty($response->beagleScore)) {
update_post_meta($order_id, 'Beagle score', $response->beagleScore);
}
if ($this->eway_stored == 'yes') {
// payment hasn't happened yet, so record status as 'on-hold' and reduce stock in anticipation
$order->reduce_order_stock();
$order->update_status('on-hold', 'Awaiting stored payment');
unset($_SESSION['order_awaiting_payment']);
}
else {
$order->payment_complete();
}
$woocommerce->cart->empty_cart();
$result = array(
'result' => 'success',
'redirect' => $this->get_return_url($order),
);
}
else {
// transaction was unsuccessful, so record transaction number and the error
$order->update_status('failed', nl2br(esc_html($response->error)));
//.........这里部分代码省略.........
示例9: array
/**
* Verify a successful Payment!
* */
function check_alphabank_response()
{
global $woocommerce;
global $wpdb;
//if (( preg_match( '/success/i', $_SERVER['REQUEST_URI'] ) && preg_match( '/alphabank/i', $_SERVER['REQUEST_URI'] ) )) {
// $merchantreference= $_GET['MerchantReference'];
$post_data_array = array();
if (isset($_POST['mid'])) {
$post_data_array[0] = $_POST['mid'];
}
if (isset($_POST['orderid'])) {
$post_data_array[1] = $_POST['orderid'];
}
if (isset($_POST['status'])) {
$post_data_array[2] = $_POST['status'];
}
if (isset($_POST['orderAmount'])) {
$post_data_array[3] = $_POST['orderAmount'];
}
if (isset($_POST['currency'])) {
$post_data_array[4] = $_POST['currency'];
}
if (isset($_POST['paymentTotal'])) {
$post_data_array[5] = $_POST['paymentTotal'];
}
if (isset($_POST['message'])) {
$post_data_array[6] = $_POST['message'];
}
if (isset($_POST['riskScore'])) {
$post_data_array[7] = $_POST['riskScore'];
}
if (isset($_POST['payMethod'])) {
$post_data_array[8] = $_POST['payMethod'];
}
if (isset($_POST['txId'])) {
$post_data_array[9] = $_POST['txId'];
}
if (isset($_POST['paymentRef'])) {
$post_data_array[10] = $_POST['paymentRef'];
}
$post_data_array[11] = $_POST['digest'];
$post_DIGEST = $_POST['digest'];
$post_data = implode("", $post_data_array);
$digest = base64_encode(sha1(utf8_encode($post_data), true));
if ($this->mode == "yes") {
//test mode
$post_url = 'https://alpha.test.modirum.com/vpos/shophandlermpi';
} else {
//live mode
$post_url = 'https://www.alphaecommerce.gr/vpos/shophandlermpi';
}
//
$ttquery = 'SELECT *
FROM `' . $wpdb->prefix . 'alphabank_transactions`
WHERE `orderid` = "' . $_POST['orderid'] . '";';
$ref = $wpdb->get_results($ttquery);
$merchantreference = $_GET['MerchantReference'];
$orderid = $ref['0']->orderid;
$order = new WC_Order($orderid);
//$order = $_POST['orderid'];
if ($_POST['status'] == 'AUTHORIZED' || $_POST['status'] == 'CAPTURED') {
//verified - successful payment
//complete order
if ($order->status == 'processing') {
$order->add_order_note(__('Payment Via alphabank<br />Transaction ID: ', 'woocommerce-alphabank-payment-gateway') . $trans_id);
//Add customer order note
$order->add_order_note(__('Payment Received.<br />Your order is currently being processed.<br />We will be shipping your order to you soon.<br />alphabank Transaction ID: ', 'woocommerce-alphabank-payment-gateway') . $trans_id, 1);
// Reduce stock levels
$order->reduce_order_stock();
// Empty cart
WC()->cart->empty_cart();
$message = __('Thank you for shopping with us.<br />Your transaction was successful, payment was received.<br />Your order is currently being processed.', 'woocommerce-alphabank-payment-gateway');
$message_type = 'success';
} else {
if ($order->has_downloadable_item()) {
//Update order status
$order->update_status('completed', __('Payment received, your order is now complete.', 'woocommerce-alphabank-payment-gateway'));
//Add admin order note
$order->add_order_note(__('Payment Via alphabank Payment Gateway<br />Transaction ID: ', 'woocommerce-alphabank-payment-gateway') . $trans_id);
//Add customer order note
$order->add_order_note(__('Payment Received.<br />Your order is now complete.<br />alphabank Transaction ID: ', 'woocommerce-alphabank-payment-gateway') . $trans_id, 1);
$message = __('Thank you for shopping with us.<br />Your transaction was successful, payment was received.<br />Your order is now complete.', 'woocommerce-alphabank-payment-gateway');
$message_type = 'success';
} else {
//Update order status
$order->update_status('processing', __('Payment received, your order is currently being processed.', 'woocommerce-alphabank-payment-gateway'));
//Add admin order note
$order->add_order_note(__('Payment Via alphabank Payment Gateway<br />Transaction ID: ', 'woocommerce-alphabank-payment-gateway') . $trans_id);
//Add customer order note
$order->add_order_note(__('Payment Received.<br />Your order is currently being processed.<br />We will be shipping your order to you soon.<br />alphabank Transaction ID: ', 'woocommerce-alphabank-payment-gateway') . $trans_id, 1);
$message = __('Thank you for shopping with us.<br />Your transaction was successful, payment was received.<br />Your order is currently being processed.', 'woocommerce-alphabank-payment-gateway');
$message_type = 'success';
}
$alphabank_message = array('message' => $message, 'message_type' => $message_type);
update_post_meta($order_id, '_alphabank_message', $alphabank_message);
// Reduce stock levels
$order->reduce_order_stock();
//.........这里部分代码省略.........
开发者ID:eellak,项目名称:woocommerce-alphabank-payment-gateway,代码行数:101,代码来源:woocommerce-alphabank-payment-gateway.php
示例10: process_payment
/**
* Process the payment and return the result
*
* @param int $order_id
* @return array
*/
public function process_payment($order_id)
{
$order = new WC_Order($order_id);
// Mark as on-hold (we're awaiting the payment)
//$order->update_status( 'on-hold', __( 'Awaiting payment', 'woocommerce' ) );
$statuses = $this->get_order_statuses();
$note = isset($statuses[$this->default_order_status]) ? $statuses[$this->default_order_status] : '';
$order->update_status($this->default_order_status, $note);
if ('yes' === $this->send_email_to_admin || 'yes' === $this->send_email_to_customer) {
$woocommerce_mailer = WC()->mailer();
if ('yes' === $this->send_email_to_admin) {
$woocommerce_mailer->emails['WC_Email_New_Order']->trigger($order_id);
}
if ('yes' === $this->send_email_to_customer) {
$woocommerce_mailer->emails['WC_Email_Customer_Processing_Order']->trigger($order_id);
}
}
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
WC()->cart->empty_cart();
// Return thankyou redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}
示例11: process_payment
/**
* Process the payment and redirect.
*
* @access public
* @param int $order_id
* @return array
*/
public function process_payment($order_id)
{
$order = new WC_Order($order_id);
// Mark as 'pending' (we're awaiting the payment)
$order->update_status('pending', __('Awaiting Stellar payment and verification.', 'woocommerce-stellar-gateway'));
// Reduce stock levels.
if ($this->debug != 'yes') {
$order->reduce_order_stock();
}
// Remove cart, leave as is if debugging.
if ($this->debug != 'yes') {
WC()->cart->empty_cart();
}
// Return to reciept page redirect.
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}
示例12: process_payment
public function process_payment( $order_id ) {
global $woocommerce;
$order = new WC_Order( $order_id );
//get payment tendered amount
$payment_amount = $_POST['payment_amount'];
//get order total
$order_total = $order->get_total();
//check for previous payments tendered and add to total payment
$tendered = get_post_meta( $order->id, 'payment_tendered', true );
$payment_amount = (float)$payment_amount + (float)$tendered;
//calculate balance after payment applied
$balance = $order_total - $payment_amount;
//if payment still needed
if( $balance > 0 ) {
//document transaction and create order note
update_post_meta( $order->id, 'payment_tendered', $payment_amount );
$order->add_order_note( __( '$ ' . round( $payment_amount, 2 ) . ' payment tendered. $ ' . round( $balance, 2 ) . ' remaining.', 'instore' ) );
$order->update_status('pending', __( 'Awaiting additional payment', 'instore' ) );
$payment_complete = false;
} else {
//resuce stock and add order note
$order->reduce_order_stock();
$order->add_order_note( __( '$ ' . round( $payment_amount, 2 ) . ' payment Tendered. Change Due $ ' . round( $balance, 2 ) . ' .', 'instore' ) );
//complete order
$order->payment_complete();
$payment_complete = true;
//empty cart
$woocommerce->cart->empty_cart();
};
//create return array
$results = array(
'result' => 'success',
'order_id' => $order_id,
'order_total' => $order_total,
'balance' => $balance,
'balance_formatted' => wc_price( -$balance ),
'payment_tendered' => wc_price( $payment_amount ),
'payment_complete' => $payment_complete,
);
//return results
return $results;
}
示例13: process_payment
public function process_payment($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
$response = simplexml_load_string($this->talk_to_upg($this->get_payment_xml($order_id)));
if ((string) $response->status == 'OK') {
$tran_id = sanitize_text_field($response->reference);
$tran_cv = sanitize_text_field($response->cv2avsresult);
$tran_ca = sanitize_text_field($response->cardtype);
$order->reduce_order_stock();
$woocommerce->cart->empty_cart();
$order->add_order_note(__('TRANSATION: ' . $tran_id . ' - CV2: ' . $tran_cv . ' - CARD: ' . $tran_ca, 'woothemes'));
$order->payment_complete($tran_id);
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
} else {
$this->handle_payment_error($response->statustext, $response->reason);
return;
}
}
开发者ID:BeeHealthLimited,项目名称:WooCommerce-UPG-XML-Direct-Payment-Gateway,代码行数:19,代码来源:woocommerce-upg-api-gateway.php
示例14: array
/**
* Process the payment and return the result
*
* @access public
* @param int $order_id
* @return array
*/
function process_payment($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
// Mark as on-hold (we're awaiting the payment)
$order->update_status('on-hold', __('Awaiting BACS payment', 'woocommerce'));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$woocommerce->cart->empty_cart();
// Return thankyou redirect
return array('result' => 'success', 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('thanks')))));
}
示例15: unset
/**
* Process the payment and return the result
*
*/
function process_payment($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
// Mark as on-hold (we're awaiting the invoice)
$order->update_status('on-hold', __('Awaiting payment', 'dp_wc_invoice'));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$woocommerce->cart->empty_cart();
// Empty awaiting payment session
unset($woocommerce->session->order_awaiting_payment);
// Return thankyou redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}