本文整理汇总了PHP中WC_Order::has_status方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::has_status方法的具体用法?PHP WC_Order::has_status怎么用?PHP WC_Order::has_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::has_status方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: payment_status_completed
/**
* Handle a completed payment
* @param WC_Order $order
*/
private function payment_status_completed($order, $posted)
{
if ($order->has_status('completed')) {
$this->log('Aborting, Order #' . $order->id . ' is already complete.');
exit;
}
$this->validate_transaction_type($posted['txn_type']);
$this->validate_currency($order, $posted['mc_currency']);
$this->validate_amount($order, $posted['mc_gross']);
$this->validate_receiver_email($order, $posted['receiver_email']);
$this->save_paypal_meta_data($order, $posted);
if ('completed' === $posted['payment_status']) {
$this->payment_complete($order, !empty($posted['txn_id']) ? wc_clean($posted['txn_id']) : '', __('IPN payment completed', 'woocommerce'));
} else {
$this->payment_on_hold($order, sprintf(__('Payment pending: %s', 'woocommerce'), $posted['pending_reason']));
}
}
示例2: email_instructions
/**
* Add content to the WC emails.
*
* @access public
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
*
* @return void
*/
public function email_instructions($order, $sent_to_admin, $plain_text = false)
{
if (!$sent_to_admin && 'bKash' === $order->payment_method && $order->has_status('on-hold')) {
if ($this->instructions) {
echo wpautop(wptexturize($this->instructions)) . PHP_EOL;
}
}
}
示例3: email_instructions
/**
* Add content to the WC emails.
*
* Note: The difference from WC_Gateway_BACS is that we use __() before
* passing the string through wptexturize() and wpautop().
*
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
*/
public function email_instructions($order, $sent_to_admin, $plain_text = false)
{
if (!$sent_to_admin && 'bacs' === $order->payment_method && $order->has_status('on-hold')) {
if ($this->instructions) {
echo wpautop(wptexturize(function_exists('pll__') ? pll__($this->instructions) : __($this->instructions, 'woocommerce'))) . PHP_EOL;
}
$this->bank_details($order->id);
}
}
示例4: needs_payment
/**
* Checks if the subscription has an unpaid order or renewal order (and therefore, needs payment).
*
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return bool True if the subscription has an unpaid renewal order, false if the subscription has no unpaid renewal orders.
* @since 2.0
*/
public function needs_payment()
{
$needs_payment = false;
// First check if the subscription is pending or failed or is for $0
if (parent::needs_payment()) {
$needs_payment = true;
// Now make sure the parent order doesn't need payment
} elseif (false !== $this->order && ($this->order->needs_payment() || $this->order->has_status('on-hold'))) {
$needs_payment = true;
// And finally, check that the last renewal order doesn't need payment
} else {
$last_renewal_order_id = get_posts(array('posts_per_page' => 1, 'post_type' => 'shop_order', 'post_status' => 'any', 'fields' => 'ids', 'orderby' => 'ID', 'order' => 'DESC', 'meta_query' => array(array('key' => '_subscription_renewal', 'compare' => '=', 'value' => $this->id, 'type' => 'numeric'))));
if (!empty($last_renewal_order_id)) {
$renewal_order = new WC_Order($last_renewal_order_id[0]);
if ($renewal_order->needs_payment() || $renewal_order->has_status(array('on-hold', 'failed', 'cancelled'))) {
$needs_payment = true;
}
}
}
return apply_filters('woocommerce_subscription_needs_payment', $needs_payment, $this);
}
示例5: switch
/**
* This part is returnurl function for epayph
*
* @global mixed $woocommerce
*/
function check_epayph_response_returnurl($posted)
{
global $woocommerce;
if (!empty($_POST) && $this->validate_ipn()) {
$order = new WC_Order($_POST['invoice']);
switch ($_REQUEST['payment_status']) {
case 'Completed':
$order->add_order_note('ePay.ph Payment Status: SUCCESSFUL' . '<br>Transaction ID: ' . $tranID . $referer);
$order->payment_complete();
wp_redirect($order->get_checkout_order_received_url());
break;
case 'Pending':
if ($order->has_status('completed')) {
exit;
} else {
$order->add_order_note('ePay.ph Payment Status: PENDING');
$order->update_status('pending', __('Awaiting Payment Approval', 'woocommerce'));
//wp_redirect($order->get_checkout_order_received_url());
}
break;
case 'Cancelled':
$order->add_order_note('ePay.ph Payment Status: FAILED');
$order->update_status('failed', __('Payment Failed', 'woocommerce'));
//wp_redirect($order->get_cancel_order_url());
break;
case 'Refunded':
$order->add_order_note('ePay.ph Payment Status: Refunded');
$order->update_status('refunded', __('Payment Refunded', 'woocommerce'));
//wp_redirect($order->get_cancel_order_url());
break;
case 'Display':
break;
default:
$order->add_order_note('ePay.ph Payment Status: Invalid Transaction');
$order->update_status('on-hold', __('Invalid Transaction', 'woocommerce'));
//wp_redirect($order->get_cancel_order_url());
}
exit;
}
}
示例6: foreach
/**
* Successful Payment!
**/
function successful_request($posted)
{
$order = new WC_Order((int) $posted["wooorderid"]);
$var = "";
if (strlen($this->md5key) > 0) {
foreach ($posted as $key => $value) {
if ($key != "hash") {
$var .= $value;
}
}
$genstamp = md5($var . $this->md5key);
if ($genstamp != $posted["hash"]) {
echo "MD5 error";
error_log('MD5 check failed for ePay callback with order_id:' . $posted["wooorderid"]);
status_header(500);
exit;
}
}
if ($order->has_status('pending')) {
// Payment completed
$order->add_order_note(__('Callback completed', 'woocommerce-gateway-epay-dk'));
if ($this->settings["addfeetoorder"] == "yes") {
$order_fee = new stdClass();
$order_fee->id = 'epay_fee';
$order_fee->name = __('Fee', 'woocommerce-gateway-epay-dk');
$order_fee->amount = isset($posted['txnfee']) ? floatval($posted['txnfee'] / 100) : 0;
$order_fee->taxable = false;
$order_fee->tax = 0;
$order_fee->tax_data = array();
$order->add_fee($order_fee);
$order->set_total($order->order_total + floatval($posted['txnfee'] / 100));
}
$order->payment_complete();
update_post_meta((int) $posted["wooorderid"], 'Transaction ID', $posted["txnid"]);
update_post_meta((int) $posted["wooorderid"], 'Card no', $posted["cardno"]);
if (isset($posted["subscriptionid"])) {
update_post_meta((int) $posted["wooorderid"], 'Subscription ID', $posted["subscriptionid"]);
}
}
echo "OK";
status_header(200);
exit;
}
示例7: mark_order_as_cancelled
/**
* Mark the given order as cancelled and set the order note
*
* @since 2.1.0
* @param WC_Order $order the order
* @param string $error_message a message to display inside the "Payment Cancelled" order note
* @param SV_WC_Payment_Gateway_API_Response optional $response the transaction response object
*/
public function mark_order_as_cancelled($order, $message, $response = null)
{
$order_note = sprintf(_x('%s Transaction Cancelled (%s)', 'Cancelled order note', $this->text_domain), $this->get_method_title(), $message);
// Mark order as cancelled if not already set
if (!$order->has_status('cancelled')) {
$order->update_status('cancelled', $order_note);
} else {
$order->add_order_note($order_note);
}
$this->add_debug_message($message, 'error');
}
示例8: failed_subscription_sign_ups_for_order
/**
* Called when a sign up fails during the payment processing step.
*
* @param WC_Order|int $order The order or ID of the order for which subscriptions should be marked as failed.
* @since 1.0
*/
public static function failed_subscription_sign_ups_for_order($order)
{
$subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => 'parent'));
if (!empty($subscriptions)) {
if (!is_object($order)) {
$order = new WC_Order($order);
}
// Set subscription status to failed and log failure
if ($order->has_status('failed')) {
$order->update_status('failed', __('Subscription sign up failed.', 'woocommerce-subscriptions'));
}
foreach ($subscriptions as $subscription) {
try {
$subscription->payment_failed();
} catch (Exception $e) {
// translators: $1: order number, $2: error message
$subscription->add_order_note(sprintf(__('Failed to process failed payment on subscription for order #%1$s: %2$s', 'woocommerce-subscriptions'), is_object($order) ? $order->get_order_number() : $order, $e->getMessage()));
}
}
do_action('failed_subscription_sign_ups_for_order', $order);
}
}
示例9: hasOrderStatus
/**
* Checks if the WooCommerce order has this specific status
*/
public function hasOrderStatus(WC_Order $order, $status)
{
return $order->has_status($status);
}
示例10: email_instructions
/**
* Add content to the WC emails.
*
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
*/
public function email_instructions($order, $sent_to_admin, $plain_text = false)
{
if (!$sent_to_admin && 'bacs' === $order->get_payment_method() && $order->has_status('on-hold')) {
if ($this->instructions) {
echo wpautop(wptexturize($this->instructions)) . PHP_EOL;
}
$this->bank_details($order->get_id());
}
}
示例11: swr_give_older_orders_rewards
function swr_give_older_orders_rewards()
{
global $swr_settings, $woocommerce;
if (!isset($_GET['give_older_orders_rewards']) || $_GET['give_older_orders_rewards'] != 1) {
return;
}
$orders = get_posts(array('numberposts' => -1, 'post_type' => 'shop_order'));
if ($orders && count($orders) > 0) {
foreach ($orders as $order) {
if (version_compare($woocommerce->version, '2.2.0') >= 0) {
$order = new WC_Order($order->ID);
$reward = $swr_settings->get_reward_earned_for_order($order->id);
if (!$reward) {
swr_update_order_meta($order->id, false);
if ($order->has_status("completed")) {
swr_add_reward($order->id);
}
}
} else {
$terms = wp_get_object_terms($order->ID, 'shop_order_status', array('fields' => 'slugs'));
$status = isset($terms[0]) ? $terms[0] : 'pending';
$reward = $swr_settings->get_reward_earned_for_order($order->ID);
if (!$reward) {
swr_update_order_meta($order->ID, false);
if ($status == 'completed') {
swr_add_reward($order->ID);
}
}
}
}
}
}
示例12: payment_status_captured
/**
* Handle a captured payment
* @param WC_Order $order
*/
protected function payment_status_captured($order, $posted)
{
if ($order->has_status('captured')) {
WC_Gateway_Komoju::log('Aborting, Order #' . $order->id . ' is already complete.');
exit;
}
$this->validate_currency($order, $posted['currency']);
$this->validate_amount($order, $posted['grand_total'] - $posted['payment_method_fee']);
$this->save_komoju_meta_data($order, $posted);
if ('captured' === $posted['status']) {
$this->payment_complete($order, !empty($posted['external_order_num']) ? wc_clean($posted['external_order_num']) : '', __('IPN payment captured', 'woocommerce'));
if (!empty($posted['payment_method_fee'])) {
// log komoju transaction fee
update_post_meta($order->id, 'Payment Gateway Transaction Fee', wc_clean($posted['payment_method_fee']));
}
} else {
$this->payment_on_hold($order, sprintf(__('Payment pending: %s', 'woocommerce'), $posted['additional_information']));
}
}
示例13:
}
?>
</div>
</div>
<div id="content">
<div id="inner-content" class="row">
<main id="main" class="large-12 medium-12 columns" role="main">
<?php
global $woocommerce;
$order = new WC_Order($order_id);
if ($order) {
?>
<?php
if ($order->has_status('failed')) {
?>
<p class="woocommerce-thankyou-order-failed"><?php
_e('Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce');
?>
</p>
<p class="woocommerce-thankyou-order-failed-actions">
<a href="<?php
echo esc_url($order->get_checkout_payment_url());
?>
" class="button pay"><?php
_e('Pay', 'woocommerce');
?>
</a>
示例14: order_failed
/**
* Mark the given order as failed, and set the order note
*
* @param WC_Order $order the order
* @param string $order_note the order note to set
*/
public function order_failed($order, $order_note)
{
if (!$order->has_status('failed')) {
$order->update_status('failed', $order_note);
} else {
// otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times
$order->add_order_note($order_note);
}
}
示例15: my_orders_actions
/**
* My Orders custom actions.
* Remove the pay button when the booking requires confirmation.
*
* @param array $actions
* @param WC_Order $order
* @return array
*/
public function my_orders_actions($actions, $order)
{
global $wpdb;
if ($order->has_status('pending') && 'wc-booking-gateway' === $order->payment_method) {
$status = array();
foreach ($order->get_items() as $order_item_id => $item) {
if ('line_item' == $item['type']) {
$_status = $wpdb->get_col($wpdb->prepare("\n\t\t\t\t\t\tSELECT posts.post_status\n\t\t\t\t\t\tFROM {$wpdb->postmeta} AS postmeta\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} AS posts ON (postmeta.post_id = posts.ID)\n\t\t\t\t\t\tWHERE postmeta.meta_key = '_booking_order_item_id'\n\t\t\t\t\t\tAND postmeta.meta_value = %d\n\t\t\t\t\t", $order_item_id));
$status = array_merge($status, $_status);
}
}
if (in_array('pending-confirmation', $status) && isset($actions['pay'])) {
unset($actions['pay']);
}
}
return $actions;
}