本文整理汇总了PHP中WC_Order::add_order_note方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::add_order_note方法的具体用法?PHP WC_Order::add_order_note怎么用?PHP WC_Order::add_order_note使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::add_order_note方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_tracking_code
/**
* Save tracking code.
*
* @param int $post_id Current post type ID.
*
* @return void
*/
public function save_tracking_code($post_id)
{
if (isset($_POST['correios_tracking'])) {
$old = get_post_meta($post_id, 'correios_tracking', true);
$new = $_POST['correios_tracking'];
if ($new && $new != $old) {
update_post_meta($post_id, 'correios_tracking', $new);
// Gets order data.
$order = new WC_Order($post_id);
// Add order note.
$order->add_order_note(sprintf(__('Added a Correios tracking code: %s', 'woocommerce-correios'), $new));
// Send email notification.
$this->trigger_email_notification($order, $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, 'correios_tracking', $old);
}
}
}
示例2: new_comment
/**
* Submit a comment for an order
*
* @param object $orders
*
* @return unknown
*/
public static function new_comment($orders)
{
global $woocommerce;
$user = wp_get_current_user();
$user = $user->ID;
// Security
if (!wp_verify_nonce($_POST['_wpnonce'], 'add-comment')) {
return false;
}
// Check if this product belongs to the vendor submitting the comment
$product_id = (int) $_POST['product_id'];
$author = PV_Vendors::get_vendor_from_product($product_id);
if ($author != $user) {
return false;
}
// Find the order belonging to this comment
foreach ($orders as $order) {
if ($order->order_id == $_POST['order_id']) {
$found_order = $order;
break;
}
}
// No order was found
if (empty($found_order)) {
return false;
}
// Don't submit empty comments
if (empty($_POST['comment_text'])) {
if (function_exists('wc_add_error')) {
wc_add_error(__('You\'ve left the comment field empty!', 'wc_product_vendor'));
} else {
$woocommerce->add_error(__('You\'ve left the comment field empty!', 'wc_product_vendor'));
}
return false;
}
// Only submit if the order has the product belonging to this vendor
$found_order = new WC_Order($found_order->order_id);
$valid_order = false;
foreach ($found_order->get_items() as $item) {
if ($item['product_id'] == $product_id) {
$valid_order = true;
break;
}
}
if ($valid_order) {
$comment = esc_textarea($_POST['comment_text']);
add_filter('woocommerce_new_order_note_data', array(__CLASS__, 'filter_comment'), 10, 2);
$found_order->add_order_note($comment, 1);
remove_filter('woocommerce_new_order_note_data', array(__CLASS__, 'filter_comment'), 10, 2);
if (function_exists('wc_add_message')) {
wc_add_message(__('Success. The customer has been notified of your comment.', 'wc_product_vendor'));
} else {
$woocommerce->add_message(__('Success. The customer has been notified of your comment.', 'wc_product_vendor'));
}
}
}
示例3: 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
示例4: 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);
// Add meta
update_post_meta($order_id, '_booking_order', '1');
// Add custom order note.
$order->add_order_note(__('This order is awaiting confirmation from the shop manager', 'woocommerce-bookings'));
// Remove cart
WC()->cart->empty_cart();
// Return thankyou redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}
示例5: webhook_handler
public function webhook_handler()
{
header('HTTP/1.1 200 OK');
$obj = file_get_contents('php://input');
$json = json_decode($obj);
if ($json->type == 'charge.succeeded') {
$order_id = $json->transaction->order_id;
$payment_date = date("Y-m-d", $json->event_date);
$order = new WC_Order($order_id);
update_post_meta($order->id, 'openpay_payment_date', $payment_date);
$order->payment_complete();
$order->add_order_note(sprintf("Payment completed."));
}
}
示例6: webhook_handler
/**
* Updates the status of the order.
* Webhook needs to be added to Conekta account tusitio.com/wc-api/WC_Conekta_Cash_Gateway
*/
public function webhook_handler()
{
header('HTTP/1.1 200 OK');
$body = @file_get_contents('php://input');
$event = json_decode($body);
$charge = $event->data->object;
$order_id = $charge->reference_id;
$paid_at = date("Y-m-d", $charge->paid_at);
$order = new WC_Order($order_id);
if (strpos($event->type, "charge.paid") !== false) {
update_post_meta($order->id, 'conekta-paid-at', $paid_at);
$order->payment_complete();
$order->add_order_note(sprintf("Payment completed in Oxxo and notification of payment received"));
}
}
示例7: explode
function check_ipn_response()
{
global $woocommerce;
$posted = $_POST['payment'];
$hash = sha1(md5($posted . $this->merchant_password));
if (isset($_POST['payment']) && $hash === $_POST['signature']) {
$items = explode("&", $_POST['payment']);
$ar = array();
foreach ($items as $it) {
$key = "";
$value = "";
list($key, $value) = explode("=", $it, 2);
$payment_items[$key] = $value;
}
$order = new WC_Order($payment_items['order']);
$order->update_status('processing', __('Платеж успешно оплачен', 'woocommerce'));
$order->add_order_note(__('Клиент успешно оплатил заказ', 'woocommerce'));
$woocommerce->cart->empty_cart();
} else {
wp_die('IPN Request Failure');
}
}
示例8: 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;
}
示例9: process_payment
public function process_payment($order_id)
{
global $woocommerce;
$customer_order = new WC_Order($order_id);
$environment = $this->environment == "yes" ? 'TRUE' : 'FALSE';
$environment_url = "FALSE" == $environment ? 'https://secure.authorize.net/gateway/transact.dll' : 'https://test.authorize.net/gateway/transact.dll';
$payload = array("x_tran_key" => $this->trans_key, "x_login" => $this->api_login, "x_version" => "3.1", "x_amount" => $customer_order->order_total, "x_card_num" => str_replace(array(' ', '-'), '', $_POST['GP_authorize_gateway-card-number']), "x_card_code" => isset($_POST['GP_authorize_gateway-card-cvc']) ? $_POST['GP_authorize_gateway-card-cvc'] : '', "x_exp_date" => str_replace(array('/', ' '), '', $_POST['GP_authorize_gateway-card-expiry']), "x_type" => 'AUTH_CAPTURE', "x_invoice_num" => str_replace("#", "", $customer_order->get_order_number()), "x_test_request" => $environment, "x_delim_char" => '|', "x_encap_char" => '', "x_delim_data" => "TRUE", "x_relay_response" => "FALSE", "x_method" => "CC", "x_first_name" => $customer_order->billing_first_name, "x_last_name" => $customer_order->billing_last_name, "x_address" => $customer_order->billing_address_1, "x_city" => $customer_order->billing_city, "x_state" => $customer_order->billing_state, "x_zip" => $customer_order->billing_postcode, "x_country" => $customer_order->billing_country, "x_phone" => $customer_order->billing_phone, "x_email" => $customer_order->billing_email, "x_ship_to_first_name" => $customer_order->shipping_first_name, "x_ship_to_last_name" => $customer_order->shipping_last_name, "x_ship_to_company" => $customer_order->shipping_company, "x_ship_to_address" => $customer_order->shipping_address_1, "x_ship_to_city" => $customer_order->shipping_city, "x_ship_to_country" => $customer_order->shipping_country, "x_ship_to_state" => $customer_order->shipping_state, "x_ship_to_zip" => $customer_order->shipping_postcode, "x_cust_id" => $customer_order->user_id, "x_customer_ip" => $_SERVER['REMOTE_ADDR']);
$response = wp_remote_post($environment_url, array('method' => 'POST', 'body' => http_build_query($payload), 'timeout' => 90, 'sslverify' => false));
if (is_wp_error($response)) {
do_action('gp_order_online_completed_failed', $response);
}
if (empty($response['body'])) {
do_action('gp_order_online_completed_failed', $response);
}
$response_body = wp_remote_retrieve_body($response);
// Parse the response into something we can read
foreach (preg_split("/\r?\n/", $response_body) as $line) {
$resp = explode("|", $line);
}
// Get the values we need
$r['response_code'] = $resp[0];
$r['response_sub_code'] = $resp[1];
$r['response_reason_code'] = $resp[2];
$r['response_reason_text'] = $resp[3];
if ($r['response_code'] == 1 || $r['response_code'] == 4) {
$customer_order->add_order_note(__('Authorize.net payment completed.', 'GP_authorize_gateway'));
if ($this->mark_order == 'yes') {
$woocommerce->cart->empty_cart();
$customer_order->payment_complete();
$customer_order->update_status('completed');
}
do_action('gp_order_online_completed_successfully', $response);
return array('result' => 'success', 'redirect' => $this->get_return_url($customer_order));
} else {
do_action('gp_error_occurred', $r['response_reason_text']);
}
}
示例10: process_order_status
/**
* Process the order status.
*
* @param WC_Order $order
* @param string $payment_id
* @param string $status
* @param string $auth_code
*
* @return bool
*/
public function process_order_status($order, $payment_id, $status, $auth_code)
{
if ('APPROVED' == $status) {
// Payment complete
$order->payment_complete($payment_id);
// Add order note
$order->add_order_note(sprintf(__('Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce'), $payment_id, $auth_code));
// Remove cart
WC()->cart->empty_cart();
return true;
}
return false;
}
示例11: woocommerce_add_order_note
function woocommerce_add_order_note()
{
global $woocommerce;
check_ajax_referer('add-order-note', 'security');
$post_id = (int) $_POST['post_id'];
$note = strip_tags(woocommerce_clean($_POST['note']));
$note_type = $_POST['note_type'];
$is_customer_note = $note_type == 'customer' ? 1 : 0;
if ($post_id > 0) {
$order = new WC_Order($post_id);
$comment_id = $order->add_order_note($note, $is_customer_note);
echo '<li rel="' . $comment_id . '" class="note ';
if ($is_customer_note) {
echo 'customer-note';
}
echo '"><div class="note_content">';
echo wpautop(wptexturize($note));
echo '</div><p class="meta">' . sprintf(__('added %s ago', 'woocommerce'), human_time_diff(current_time('timestamp'))) . ' - <a href="#" class="delete_note">' . __('Delete note', 'woocommerce') . '</a></p>';
echo '</li>';
}
// Quit out
die;
}
示例12: executepay
public function executepay()
{
if (empty(WC()->session->token) || empty(WC()->session->PayerID) || empty(WC()->session->paymentId)) {
return;
}
$execution = new PaymentExecution();
$execution->setPayerId(WC()->session->PayerID);
try {
$payment = Payment::get(WC()->session->paymentId, $this->getAuth());
$payment->execute($execution, $this->getAuth());
$this->add_log(print_r($payment, true));
if ($payment->state == "approved") {
//if state = approved continue..
global $wpdb;
$this->log->add('paypal_plus', sprintf(__('Response: %s', 'paypal-for-woocommerce'), print_r($payment, true)));
$order = new WC_Order(WC()->session->orderId);
if ($this->billing_address == 'yes') {
require_once "lib/NameParser.php";
$parser = new FullNameParser();
$split_name = $parser->split_full_name($payment->payer->payer_info->shipping_address->recipient_name);
$shipping_first_name = $split_name['fname'];
$shipping_last_name = $split_name['lname'];
$full_name = $split_name['fullname'];
update_post_meta(WC()->session->orderId, '_billing_first_name', $shipping_first_name);
update_post_meta(WC()->session->orderId, '_billing_last_name', $shipping_last_name);
update_post_meta(WC()->session->orderId, '_billing_full_name', $full_name);
update_post_meta(WC()->session->orderId, '_billing_address_1', $payment->payer->payer_info->shipping_address->line1);
update_post_meta(WC()->session->orderId, '_billing_address_2', $payment->payer->payer_info->shipping_address->line2);
update_post_meta(WC()->session->orderId, '_billing_city', $payment->payer->payer_info->shipping_address->city);
update_post_meta(WC()->session->orderId, '_billing_postcode', $payment->payer->payer_info->shipping_address->postal_code);
update_post_meta(WC()->session->orderId, '_billing_country', $payment->payer->payer_info->shipping_address->country_code);
update_post_meta(WC()->session->orderId, '_billing_state', $payment->payer->payer_info->shipping_address->state);
}
$order->add_order_note(__('PayPal Plus payment completed', 'paypal-for-woocommerce'));
$order->payment_complete($payment->id);
//add hook
do_action('woocommerce_checkout_order_processed', WC()->session->orderId);
wp_redirect($this->get_return_url($order));
}
} catch (PayPal\Exception\PayPalConnectionException $ex) {
wc_add_notice(__("Error processing checkout. Please try again. ", 'woocommerce'), 'error');
$this->add_log($ex->getData());
} catch (Exception $ex) {
$this->add_log($ex->getMessage());
// Prints the Error Code
wc_add_notice(__("Error processing checkout. Please try again.", 'woocommerce'), 'error');
}
}
示例13: update_order_status
/**
* Update order status.
*
* @param array $posted PagSeguro post data.
*/
public function update_order_status($posted)
{
if (isset($posted->reference)) {
$order_id = (int) str_replace($this->invoice_prefix, '', $posted->reference);
$order = new WC_Order($order_id);
// Checks whether the invoice number matches the order.
// If true processes the payment.
if ($order->id === $order_id) {
if ('yes' == $this->debug) {
$this->log->add($this->id, 'PagSeguro payment status for order ' . $order->get_order_number() . ' is: ' . intval($posted->status));
}
// Order details.
$order_details = array('type' => '', 'method' => '', 'installments' => '', 'link' => '');
if (isset($posted->code)) {
update_post_meta($order->id, __('PagSeguro Transaction ID', 'woocommerce-pagseguro'), (string) $posted->code);
}
if (isset($posted->sender->email)) {
update_post_meta($order->id, __('Payer email', 'woocommerce-pagseguro'), (string) $posted->sender->email);
}
if (isset($posted->sender->name)) {
update_post_meta($order->id, __('Payer name', 'woocommerce-pagseguro'), (string) $posted->sender->name);
}
if (isset($posted->paymentMethod->type)) {
$order_details['type'] = intval($posted->paymentMethod->type);
update_post_meta($order->id, __('Payment type', 'woocommerce-pagseguro'), $this->api->get_payment_name_by_type($order_details['type']));
}
if (isset($posted->paymentMethod->code)) {
$order_details['method'] = $this->api->get_payment_method_name(intval($posted->paymentMethod->code));
update_post_meta($order->id, __('Payment method', 'woocommerce-pagseguro'), $order_details['method']);
}
if (isset($posted->installmentCount)) {
$order_details['installments'] = (string) $posted->installmentCount;
update_post_meta($order->id, __('Installments', 'woocommerce-pagseguro'), $order_details['installments']);
}
if (isset($posted->paymentLink)) {
$order_details['link'] = (string) $posted->paymentLink;
update_post_meta($order->id, __('Payment url', 'woocommerce-pagseguro'), $order_details['link']);
}
// Save/update payment information for transparente checkout.
if ('transparent' == $this->method) {
update_post_meta($order->id, '_wc_pagseguro_payment_data', $order_details);
}
switch (intval($posted->status)) {
case 1:
$order->update_status('on-hold', __('PagSeguro: The buyer initiated the transaction, but so far the PagSeguro not received any payment information.', 'woocommerce-pagseguro'));
break;
case 2:
$order->update_status('on-hold', __('PagSeguro: Payment under review.', 'woocommerce-pagseguro'));
break;
case 3:
$order->add_order_note(__('PagSeguro: Payment approved.', 'woocommerce-pagseguro'));
// For WooCommerce 2.2 or later.
add_post_meta($order->id, '_transaction_id', (string) $posted->code, true);
// Changing the order for processing and reduces the stock.
$order->payment_complete();
break;
case 4:
$order->add_order_note(__('PagSeguro: Payment completed and credited to your account.', 'woocommerce-pagseguro'));
break;
case 5:
$order->update_status('on-hold', __('PagSeguro: Payment came into dispute.', 'woocommerce-pagseguro'));
$this->send_email(sprintf(__('Payment for order %s came into dispute', 'woocommerce-pagseguro'), $order->get_order_number()), __('Payment in dispute', 'woocommerce-pagseguro'), sprintf(__('Order %s has been marked as on-hold, because the payment came into dispute in PagSeguro.', 'woocommerce-pagseguro'), $order->get_order_number()));
break;
case 6:
$order->update_status('refunded', __('PagSeguro: Payment refunded.', 'woocommerce-pagseguro'));
$this->send_email(sprintf(__('Payment for order %s refunded', 'woocommerce-pagseguro'), $order->get_order_number()), __('Payment refunded', 'woocommerce-pagseguro'), sprintf(__('Order %s has been marked as refunded by PagSeguro.', 'woocommerce-pagseguro'), $order->get_order_number()));
break;
case 7:
$order->update_status('cancelled', __('PagSeguro: Payment canceled.', 'woocommerce-pagseguro'));
break;
default:
// No action xD.
break;
}
} else {
if ('yes' == $this->debug) {
$this->log->add($this->id, 'Error: Order Key does not match with PagSeguro reference.');
}
}
}
}
示例14: save
/**
* Save metabox data.
*
* @param int $post_id Current post type ID.
*
* @return void
*/
public function save($post_id)
{
// Verify nonce.
if (!isset($_POST['wcboleto_metabox_nonce']) || !wp_verify_nonce($_POST['wcboleto_metabox_nonce'], basename(__FILE__))) {
return $post_id;
}
// Verify if this is an auto save routine.
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// Check permissions.
if ('shop_order' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
if (isset($_POST['wcboleto_expiration_date']) && !empty($_POST['wcboleto_expiration_date'])) {
// Gets boleto data.
$boleto_data = get_post_meta($post_id, 'wc_boleto_data', true);
$boleto_data['data_vencimento'] = sanitize_text_field($_POST['wcboleto_expiration_date']);
// Update boleto data.
update_post_meta($post_id, 'wc_boleto_data', $boleto_data);
// Gets order data.
$order = new WC_Order($post_id);
// Add order note.
$order->add_order_note(sprintf(__('Expiration date updated to: %s', 'wcboleto'), $boleto_data['data_vencimento']));
// Send email notification.
$this->email_notification($order, $boleto_data['data_vencimento']);
}
}
示例15: payment_fail
/**
* Payment failed process
*
* @param WC_Order $order
* @param $reason
* @param null $order_note
* @param null $custom_order_note
*
* @return string
*/
protected function payment_fail(WC_Order $order, $reason, $order_note = null, $custom_order_note = null)
{
wc_add_notice($reason, 'error');
if ($order_note) {
$order->add_order_note($order_note);
}
if ($this->get_option('enable_custom_order_note') == 'yes' && strlen($custom_order_note) > 0) {
$order->add_order_note($custom_order_note);
}
$order->update_status('failed', __('Payment was declined by LUUP.', 'woocommerce'));
}