本文整理汇总了PHP中WC_Order::get_order方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_order方法的具体用法?PHP WC_Order::get_order怎么用?PHP WC_Order::get_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::get_order方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_order
/**
* Retrieve an order.
*
* @param int $order_id
* @return WC_Order or null
*/
public static function get_order($order_id = '')
{
$result = null;
$order = new WC_Order($order_id);
if ($order->get_order($order_id)) {
$result = $order;
}
return $result;
}
示例2: getWcOrder
/**
* Get WooCommerce order
*
* @param int $order_id Order ID
* @return WC_Order|bool
*/
public function getWcOrder($order_id)
{
if (function_exists('wc_get_order')) {
/**
* @since WooCommerce 2.2
*/
return wc_get_order($order_id);
}
$order = new WC_Order();
if ($order->get_order($order_id)) {
return $order;
}
return false;
}
示例3: header
function meowallet_response()
{
global $woocommerce;
@ob_clean();
global $woocommerce;
$order = new WC_Order($order_id);
MEOWallet_Config::$isProduction = $this->environment == 'production' ? TRUE : FALSE;
if ($this->environment == 'production') {
MEOWallet_Config::$apikey = $this->apikey_live;
} else {
MEOWallet_Config::$apikey = $this->apikey_sandbox;
}
$_notification = new MEOWallet_Notify();
if (in_array('NEW', $_notification->payment['status'])) {
// header('Location: ' . $url_redirect);
header('HTTP/1.1 200 OK');
if ($order->get_order($_notification->order_id) == TRUE) {
$_notification = MEOWallet_Trasact::status($_notification->order_id);
do_action("wallet-request", $_notification);
}
}
}
示例4: foreach
<thead>
<tr>
<th class="order-number"><span class="nobr"><?php
_e('Order', 'woocommerce');
?>
</span></th>
<th class="actions"><span class="nobr"><?php
_e('Actions', 'follow_up_emails');
?>
</span></th>
</tr>
</thead>
<tbody>
<?php
foreach ($my_emails as $email) {
$order->get_order($email->order_id);
?>
<tr>
<td class="order-number">
<a href="<?php
echo esc_url(add_query_arg('order', $email->order_id, get_permalink(woocommerce_get_page_id('view_order'))));
?>
">
<?php
echo $order->get_order_number();
?>
</a>
–
<em>(<?php
printf(_n('1 email', '%d emails', $email->num, 'follow_up_emails'), $email->num);
?>
示例5: urlencode
/** ************************************************************************
* Recommended. This is a custom column method and is responsible for what
* is rendered in any column with a name/slug of 'title'. Every time the class
* needs to render a column, it first looks for a method named
* column_{$column_title} - if it exists, that method is run. If it doesn't
* exist, column_default() is called instead.
*
* This example also illustrates how to implement rollover actions. Actions
* should be an associative array formatted as 'slug'=>'link html' - and you
* will need to generate the URLs yourself. You could even ensure the links
*
*
* @see WP_List_Table::::single_row_columns()
* @param array $item A singular item (one full row's worth of data)
* @return string Text to be placed inside the column <td> (profile title only)
**************************************************************************/
function column_details($item)
{
// get current page with paging as url param
$page = $_REQUEST['page'];
if (isset($_REQUEST['paged'])) {
$page .= '&paged=' . $_REQUEST['paged'];
}
if (isset($_REQUEST['s'])) {
$page .= '&s=' . urlencode($_REQUEST['s']);
}
if (isset($_REQUEST['order_status'])) {
$page .= '&order_status=' . $_REQUEST['order_status'];
}
//Build row actions
$actions = array('view_ebay_order_details' => sprintf('<a href="?page=%s&action=%s&ebay_order=%s&width=600&height=470" class="thickbox">%s</a>', $page, 'view_ebay_order_details', $item['id'], __('Details', 'wplister')));
// try to find created order
$order_post_id = $item['post_id'];
$order_exists = false;
$order_msg = '';
if ($order_post_id) {
$order = new WC_Order();
if ($order->get_order($order_post_id)) {
// order exists - but might be trashed
if ($order->post_status == 'trash') {
$order_msg = '<br><small style="color:darkred;">Order #' . $order_post_id . ' has been trashed.</small>';
} else {
$order_exists = true;
$order_msg = '<br><small>Order ' . $order->get_order_number() . ' is ' . $order->get_status() . '.</small>';
}
} else {
// order does not exist - probably deleted
$order_msg = '<br><small style="color:darkred;">Order #' . $order_post_id . ' has been deleted.</small>';
}
}
// create or edit order link
if ($order_exists) {
$actions['edit_order'] = sprintf('<a href="post.php?action=%s&post=%s">%s</a>', 'edit', $item['post_id'], __('View Order', 'wplister'));
} else {
$actions['create_order'] = sprintf('<a href="?page=%s&action=%s&ebay_order=%s">%s</a>', $page, 'create_order', $item['id'], __('Create Order', 'wplister'));
}
// free version can't create orders
if (WPLISTER_LIGHT) {
unset($actions['create_order']);
}
// item title
$title = $item['buyer_name'];
if ($item['buyer_userid']) {
$title .= ' <i style="color:silver">' . $item['buyer_userid'] . '</i>';
}
$item_details = maybe_unserialize($item['details']);
if ($item_details) {
if ($item_details->IsMultiLegShipping) {
$title .= '<br><small>Global Shipping Program</small>';
}
}
//Return the title contents
return sprintf('%1$s %2$s', $title . $order_msg, $this->row_actions($actions));
}
示例6: header
/**
* Check for Veritrans Web Response
* Method ini akan dipanggil untuk merespon notifikasi yang
* diberikan oleh server Veritrans serta melakukan verifikasi
* apakah notifikasi tersebut berasal dari Veritrans dan melakukan
* konfirmasi transaksi pembayaran yang dilakukan customer
*
* update: sekaligus untuk menjadi finish/failed URL handler.
* @access public
* @return void
*/
function veritrans_vtweb_response()
{
global $woocommerce;
@ob_clean();
global $woocommerce;
$order = new WC_Order($order_id);
Veritrans_Config::$isProduction = $this->environment == 'production' ? true : false;
if ($this->environment == 'production') {
Veritrans_Config::$serverKey = $this->server_key_v2_production;
} else {
Veritrans_Config::$serverKey = $this->server_key_v2_sandbox;
}
// check whether the request is GET or POST,
// if request == GET, request is for finish OR failed URL, then redirect to WooCommerce's order complete/failed
// else if request == POST, request is for payment notification, then update the payment status
if (!isset($_GET['order_id'])) {
// Check if POST, then create new notification
$veritrans_notification = new Veritrans_Notification();
if (in_array($veritrans_notification->status_code, array(200, 201, 202))) {
header('HTTP/1.1 200 OK');
if ($order->get_order($veritrans_notification->order_id) == true) {
$veritrans_confirmation = Veritrans_Transaction::status($veritrans_notification->order_id);
do_action("valid-veritrans-web-request", $veritrans_notification);
}
}
} else {
// else if GET, redirect to order complete/failed
// error_log('status_code '. $_GET['status_code']); //debug
// error_log('status_code '. $_GET['transaction_status']); //debug
if (isset($_GET['order_id']) && isset($_GET['transaction_status']) && ($_GET['transaction_status'] == 'capture' || $_GET['transaction_status'] == 'pending' || $_GET['transaction_status'] == 'settlement')) {
$order_id = $_GET['order_id'];
// error_log($this->get_return_url( $order )); //debug
$order = new WC_Order($order_id);
wp_redirect($order->get_checkout_order_received_url());
} else {
if (isset($_GET['order_id']) && isset($_GET['transaction_status']) && $_GET['transaction_status'] == 'deny') {
$order_id = $_GET['order_id'];
$order = new WC_Order($order_id);
wp_redirect($order->get_checkout_payment_url(false));
} else {
if (isset($_GET['order_id']) && !isset($_GET['transaction_status'])) {
// if customer click "back" button, redirect to checkout page again
$order_id = $_GET['order_id'];
$order = new WC_Order($order_id);
wp_redirect($order->get_checkout_payment_url(false));
}
}
}
}
}
示例7: explode
//.........这里部分代码省略.........
exit;
}
if ((int) $P_AMT != (int) $order->get_total()) {
//입금액 체크
echo 'FAIL_M14';
exit;
}
update_post_meta($order->id, 'inicis_vbank_noti_received', 'yes');
update_post_meta($order->id, 'inicis_vbank_noti_received_tid', $P_TID);
$order->add_order_note(sprintf(__('입금통보 내역이 수신되었습니다. 가맹점 관리자에서 주문 확인후 처리해주세요. 전송서버IP : %s, 거래번호(TID) : %s, 상점거래번호(OID) : %s, 입금은행코드 : %s, 입금은행명 : %s, 입금가상계좌번호 : %s, 입금액 : %s, 입금자명 : %s', 'inicis_payment'), $PGIP, $P_TID, $P_OID, $P_FN_CD1, mb_convert_encoding($P_FN_NM, "UTF-8", "EUC-KR"), $p_vacct_no, number_format($P_AMT), mb_convert_encoding($P_UNAME, "UTF-8", "EUC-KR")));
$order->payment_complete();
$order->update_status($this->settings['order_status_after_vbank_noti']);
echo 'OK';
exit;
} else {
//주문상태가 이상한 경우
$order->add_order_note(sprintf(__('입금통보 내역이 수신되었으나, 주문 상태가 문제가 있습니다. 이미 완료된 주문이거나, 환불된 주문일 수 있습니다. 전송서버IP : %s, 거래번호(TID) : %s, 상점거래번호(OID) : %s, 입금은행코드 : %s, 입금은행명 : %s, 입금가상계좌번호 : %s, 입금액 : %s, 입금자명 : %s', 'inicis_payment'), $PGIP, $P_TID, $P_OID, $P_FN_CD1, mb_convert_encoding($P_FN_NM, "UTF-8", "EUC-KR"), $p_vacct_no, number_format($P_AMT), mb_convert_encoding($P_UNAME, "UTF-8", "EUC-KR")));
echo 'FAIL_20';
//가맹점 관리자 사이트에서 재전송 가능하나 주문건 확인 필요
exit;
}
} else {
echo "OK";
return;
}
}
$notification = $this->decrypt_notification($_POST['P_NOTI']);
if (empty($notification)) {
$this->inicis_print_log(__('유효하지않은 주문입니다. (invalid notification)', 'inicis_payment'));
echo "FAIL";
exit;
}
$txnid = $notification->txnid;
$hash = $notification->hash;
if ($_REQUEST['P_STATUS'] == '00' && !empty($txnid)) {
$userid = get_current_user_id();
$orderid = explode('_', $txnid);
$orderid = (int) $orderid[0];
$order = new WC_Order($orderid);
if (empty($order) || !is_numeric($orderid) || $order->get_order($orderid) == false) {
$this->inicis_print_log(__('유효하지않은 주문입니다. (invalid orderid)', 'inicis_payment'));
echo "FAIL";
exit;
}
$productinfo = $this->make_product_info($order);
$order_total = $this->inicis_get_order_total($order);
if ($order->get_status() == 'failed' || $order->get_status() == 'cancelled') {
$this->inicis_print_log(sprintf(__('주문요청(%s)에 대한 상태(%s)가 유효하지 않습니다.', 'inicis_payment'), $txnid, __($order->get_status(), 'woocommerce')));
$order->add_order_note(sprintf(__('<font color="red">주문요청(%s)에 대한 상태(%s)가 유효하지 않습니다.</font>', 'inicis_payment'), $txnid, __($order->get_status(), 'woocommerce')));
$rst = $this->cancel_request($_REQUEST['P_TID'], __('주문시간 초과오류 : 자동결재취소', 'inicis_payment'), __('CM_CANCEL_100', 'inicis_payment'));
if ($rst == "success") {
$order->add_order_note(sprintf(__('<font color="red">[결재알림]</font>주문시간 초과오류건(%s)에 대한 자동 결제취소가 진행되었습니다.', 'inicis_payment'), $_REQUEST['P_TYPE']));
update_post_meta($order->id, '_codem_inicis_order_cancelled', TRUE);
} else {
$order->add_order_note(sprintf(__('<font color="red">주문시간 초과오류건(%s)에 대한 자동 결제취소가 실패했습니다.</font>', 'inicis_payment'), $_REQUEST['P_TYPE']));
}
echo "FAIL";
exit;
}
if ($this->validate_txnid($order, $txnid) == false) {
$this->inicis_print_log(sprintf(__('유효하지 않은 주문번호(%s) 입니다', 'inicis_payment'), $txnid));
$order->add_order_note(sprintf(__('<font color="red">유효하지 않은 주문번호(%s) 입니다.</font>', 'inicis_payment'), $txnid));
echo "FAIL";
exit;
}
$checkhash = hash('sha512', "{$this->merchant_id}|{$txnid}||{$order_total}|{$productinfo}|{$order->billing_first_name}|{$order->billing_email}|||||||||||");
if ($hash != $checkhash) {
$this->inicis_print_log("{$this->merchant_id}|{$txnid}||{$order_total}|{$productinfo}|{$order->billing_first_name}|{$order->billing_email}|||||||||||");
$this->inicis_print_log(sprintf(__('주문요청(%s)에 대한 위변조 검사 오류입니다.', 'inicis_payment'), $txnid));
$order->add_order_note(sprintf(__('<font color="red">주문요청(%s)에 대한 위변조 검사 오류입니다.</font>', 'inicis_payment'), $txnid));
echo "FAIL";
exit;
}
$inimx_txnid = $_REQUEST['P_OID'];
$inimx_orderid = explode('_', $inimx_txnid);
$inimx_orderid = (int) $inimx_orderid[0];
if ($txnid != $inimx_txnid || $orderid != $inimx_orderid) {
$this->inicis_print_log(sprintf(__('주문요청(%s, %s, %s, %s)에 대한 위변조 검사 오류입니다. 결재는 처리되었으나, 결재요청에 오류가 있습니다. 이니시스 결재내역을 확인하신 후, 고객에게 연락을 해주시기 바랍니다.', 'inicis_payment'), $txnid, $inimx_txnid, $orderid, $inimx_orderid));
$order->add_order_note(sprintf(__('<font color="red">주문요청(%s, %s, %s, %s)에 대한 위변조 검사 오류입니다. 결재는 처리되었으나, 결재요청에 오류가 있습니다. 이니시스 결재내역을 확인하신 후, 고객에게 연락을 해주시기 바랍니다.</font>', 'inicis_payment'), $txnid, $inimx_txnid, $orderid, $inimx_orderid));
echo "FAIL";
exit;
}
add_post_meta($orderid, "inicis_paymethod", $_REQUEST['P_TYPE']);
add_post_meta($orderid, "inicis_paymethod_tid", $_REQUEST['P_TID']);
$this->inicis_print_log(sprintf(__('주문이 완료되었습니다. 결제방법 : [모바일] %s, 이니시스 거래번호(TID) : %s, 몰 고유 주문번호 : %s', 'inicis_payment'), $_REQUEST['P_TYPE'], $_REQUEST['P_TID'], $_REQUEST['P_OID']));
$order->add_order_note(sprintf(__('주문이 완료되었습니다. 결제방법 : [모바일] %s, 이니시스 거래번호(TID) : <a href="https://iniweb.inicis.com/app/publication/apReceipt.jsp?noMethod=1&noTid=%s" target=_blank>[영수증 확인]</a>, 몰 고유 주문번호 : %s', 'inicis_payment'), $_REQUEST['P_TYPE'], $_REQUEST['P_TID'], $_REQUEST['P_OID']));
$order->payment_complete();
$woocommerce->cart->empty_cart();
delete_post_meta($orderid, "ini_rn");
delete_post_meta($orderid, "ini_enctype");
//delete_post_meta($orderid, 'txnid');
echo "OK";
exit;
} else {
$this->inicis_print_log(__('유효하지않은 주문입니다. (invalid status or txnid)', 'inicis_payment'));
echo "FAIL";
exit;
}
}
}
示例8: wooOrderExists
static function wooOrderExists($post_id)
{
$_order = new WC_Order();
if ($_order->get_order($post_id)) {
// WPLE()->logger->info( 'post_status for order ID '.$post_id.' is '.$_order->post_status );
if ($_order->post_status == 'trash') {
return false;
}
return $_order->id;
}
return false;
}
示例9: process_payment
/**
* Used to proccess the payment
*
* @param int $order_id
* @return
*
*/
public function process_payment($order_id)
{
//give command to open the modal box
$token = isset($_POST['everypayToken']) ? $_POST['everypayToken'] : 0;
if (!$token) {
echo $this->show_button();
exit;
}
//continue to payment
global $error, $current_user, $woocommerce;
try {
$wc_order = new WC_Order($order_id);
$grand_total = $wc_order->order_total;
$amount = $this->format_the_amount($grand_total);
$description = get_bloginfo('name') . ' / ' . __('Order') . ' #' . $wc_order->get_order_number() . ' - ' . number_format($amount / 100, 2, ',', '.') . '€';
$data = array('description' => $description, 'amount' => $amount, 'payee_email' => $wc_order->billing_email, 'payee_phone' => $wc_order->billing_phone, 'token' => $token, 'max_installments' => $this->everypay_get_installments($amount / 100, $this->everypayMaxInstallments));
// --------------- Enable for debug -------------
/* $error = var_export($data, true);
wc_add_notice($error, $notice_type = 'error');
WC()->session->reload_checkout = true;
return; */
Everypay::setApiKey($this->everypaySecretKey);
$response = Everypay::addPayment($data);
if (isset($response['body']['error'])) {
$error = $response['body']['error']['message'];
$trimmed = trim($this->get_option('everypay_error_message'));
if (!empty($trimmed)) {
$error = $this->get_option('everypay_error_message');
}
wc_add_notice($error, $notice_type = 'error');
WC()->session->reload_checkout = true;
} else {
//wc_add_notice('Payment success!');
$dt = new DateTime("Now");
$timestamp = $dt->format('Y-m-d H:i:s e');
$token = $response['body']['token'];
$wc_order->add_order_note(__('Everypay payment completed at-' . $timestamp . '-with Token ID=' . $token, 'woocommerce'));
$wc_order->payment_complete($token);
$wc_order->get_order();
add_post_meta($order_id, 'token', $token);
WC()->cart->empty_cart();
$responseData = array('result' => 'success', 'redirect' => $this->get_return_url($wc_order));
return $responseData;
}
} catch (\Exception $e) {
$error = $e->getMessage();
$trimmed = trim($this->get_option('everypay_error_message'));
if (!empty($trimmed)) {
$error = $this->get_option('everypay_error_message');
}
wc_add_notice($error, $notice_type = 'error');
WC()->session->reload_checkout = true;
}
return;
}
示例10: unregister_order
/**
* Marks order as not handled.
* @param int $order_id
* @return boolean true if order could be marked as not handled, false on failure
*/
public static function unregister_order($order_id)
{
$unregistered = false;
$order = new WC_Order();
if ($order->get_order($order_id)) {
$r = get_post_meta($order->id, '_groups_ws_registered', true);
if (!empty($r)) {
$unregistered = delete_post_meta($order->id, '_groups_ws_registered');
}
}
return $unregistered;
}
示例11: array
/** ************************************************************************
* Recommended. This is a custom column method and is responsible for what
* is rendered in any column with a name/slug of 'title'. Every time the class
* needs to render a column, it first looks for a method named
* column_{$column_title} - if it exists, that method is run. If it doesn't
* exist, column_default() is called instead.
*
* This example also illustrates how to implement rollover actions. Actions
* should be an associative array formatted as 'slug'=>'link html' - and you
* will need to generate the URLs yourself. You could even ensure the links
*
*
* @see WP_List_Table::::single_row_columns()
* @param array $item A singular item (one full row's worth of data)
* @return string Text to be placed inside the column <td> (profile title only)
**************************************************************************/
function column_details($item)
{
//Build row actions
$actions = array('view_amazon_order_details' => sprintf('<a href="?page=%s&action=%s&amazon_order=%s&width=600&height=470" class="thickbox">%s</a>', $_REQUEST['page'], 'view_amazon_order_details', $item['id'], __('Details', 'wpla')));
// try to find created order
$order_post_id = $item['post_id'];
$order_exists = false;
$order_msg = '';
if ($order_post_id) {
$order = new WC_Order();
if ($order->get_order($order_post_id)) {
// order exists - but might be trashed
if ($order->post_status == 'trash') {
$order_msg = '<br><small style="color:darkred;">Order #' . $order_post_id . ' has been trashed.</small>';
} else {
$order_exists = true;
$order_msg = '<br><small>Order ' . $order->get_order_number() . ' is ' . $order->get_status() . '.</small>';
}
} else {
// order does not exist - probably deleted
$order_msg = '<br><small style="color:darkred;">Order #' . $order_post_id . ' has been deleted.</small>';
}
}
// create or edit order link
if ($order_exists) {
$actions['edit_order'] = sprintf('<a href="post.php?action=%s&post=%s">%s</a>', 'edit', $item['post_id'], __('View Order', 'wpla'));
} else {
}
// if items haven't been loaded, show load items link
if (!$item['items'] || strpos($item['items'], 'RequestThrottled')) {
$actions['load_order_items'] = sprintf('<a href="?page=%s&action=%s&amazon_order=%s">%s</a>', $_REQUEST['page'], 'load_order_items', $item['id'], __('Fetch Items', 'wpla'));
unset($actions['create_order']);
}
// hide create order link for Pending orders
if ($item['status'] == 'Pending') {
unset($actions['create_order']);
}
// item title
$title = $item['buyer_name'] ? $item['buyer_name'] : '<i>Unknown Buyer</i>';
if ($item['buyer_userid']) {
$title .= ' <i style="color:silver">' . $item['buyer_userid'] . '</i>';
}
$order_details = json_decode($item['details']);
if (is_object($order_details)) {
if ($order_details->SalesChannel) {
$title .= '<br><small style="color:gray;">Placed on ' . $order_details->SalesChannel . '</small>';
}
if ($order_details->FulfillmentChannel == 'AFN') {
$title .= '<br><small style="color:gray;">Fulfilled by Amazon (FBA)</small>';
}
}
//Return the title contents
return sprintf('%1$s %2$s', $title . $order_msg, $this->row_actions($actions));
}
示例12: unset
function check_ipn_response()
{
$_REQUEST['ipn'] = true;
$signatureParams = $_GET;
//These parameters are not necessary for calculating signature
if (isset($signatureParams['wc-api']) && $signatureParams['wc-api'] != '') {
unset($signatureParams['wc-api']);
}
if (isset($signatureParams['paymentwallListener']) && $signatureParams['paymentwallListener'] != '') {
unset($signatureParams['paymentwallListener']);
}
$pingback = new Paymentwall_Pingback($signatureParams, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate()) {
$goodsId = $pingback->getProduct()->getId();
$reason = $pingback->getParameter('reason');
$order = new WC_Order((int) $goodsId);
global $woocommerce;
if ($order->get_order($goodsId)) {
if ($pingback->isCancelable()) {
$order->update_status('cancelled', __('Reason: ' . $reason, 'woocommerce'));
} else {
$order->add_order_note(__('Paymentwall payment completed', 'woocommerce'));
$order->payment_complete();
$woocommerce->cart->empty_cart();
}
echo 'OK';
} else {
echo 'Paymentwall IPN Request Failure';
}
} else {
echo $pingback->getErrorSummary();
}
return;
}