当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Order::cancel_order方法代码示例

本文整理汇总了PHP中WC_Order::cancel_order方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::cancel_order方法的具体用法?PHP WC_Order::cancel_order怎么用?PHP WC_Order::cancel_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Order的用法示例。


在下文中一共展示了WC_Order::cancel_order方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ebanx_notify_response

/**
 * EBANX notification action - gets called when a payment is updated
 * @return void
 */
function ebanx_notify_response()
{
    $ebanxWC = new WC_Gateway_Ebanx();
    $hashes = isset($_REQUEST['hash_codes']) ? $_REQUEST['hash_codes'] : null;
    if (!isset($hashes)) {
        echo 'NOK: no hashes were sent.';
        return;
    }
    $hashes = explode(',', $hashes);
    foreach ($hashes as $hash) {
        try {
            $response = \Ebanx\Ebanx::doQuery(array('hash' => $hash));
            if (isset($response->status) && $response->status == 'SUCCESS') {
                $orderId = (int) $response->payment->order_number;
                $order = new WC_Order($orderId);
                if ($order) {
                    if ($response->payment->status == 'CA') {
                        $order->add_order_note('Payment cancelled via IPN.');
                        $order->cancel_order();
                        echo "OK: Payment {$hash} was cancelled via IPN";
                    } elseif ($response->payment->status == 'CO') {
                        $order->add_order_note(__('EBANX payment completed, Hash: ' . $response->payment->hash, 'woocommerce'));
                        $order->payment_complete($response->payment->order_number);
                        echo "OK: Payment {$hash} was completed";
                    } elseif ($response->payment->status == 'OP' || $response->payment->status == 'PE') {
                        echo "SKIP: Payment {$hash} is pending.";
                    }
                } else {
                    echo "NOK: payment {$hash} was not found.";
                }
            }
        } catch (Exception $e) {
            echo "NOK: payment {$hash} threw an exception => " . $e->getMessage();
        }
    }
    exit;
}
开发者ID:hdolinski,项目名称:woocommerce-ebanx-recurring,代码行数:41,代码来源:return.php

示例2: woocommerce_cancel_order

/**
 * Cancel a pending order.
 *
 * @access public
 * @return void
 */
function woocommerce_cancel_order()
{
    global $woocommerce;
    if (isset($_GET['cancel_order']) && isset($_GET['order']) && isset($_GET['order_id'])) {
        $order_key = urldecode($_GET['order']);
        $order_id = (int) $_GET['order_id'];
        $order = new WC_Order($order_id);
        if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed')) && $woocommerce->verify_nonce('cancel_order', '_GET')) {
            // Cancel the order + restore stock
            $order->cancel_order(__('Order cancelled by customer.', 'woocommerce'));
            // Message
            $woocommerce->add_message(__('Your order was cancelled.', 'woocommerce'));
            do_action('woocommerce_cancelled_order', $order->id);
        } elseif ($order->status != 'pending') {
            $woocommerce->add_error(__('Your order is no longer pending and could not be cancelled. Please contact us if you need assistance.', 'woocommerce'));
        } else {
            $woocommerce->add_error(__('Invalid order.', 'woocommerce'));
        }
        wp_safe_redirect($woocommerce->cart->get_cart_url());
        exit;
    }
}
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:28,代码来源:woocommerce-functions.php

示例3: process_subscription_payment_failure

 /**
  * Expires a single subscription on a users account.
  *
  * @param $user_id int The id of the user who owns the expiring subscription. 
  * @param $subscription_key string A subscription key of the form obtained by @see get_subscription_key( $order_id, $product_id )
  * @since 1.0
  */
 public static function process_subscription_payment_failure($user_id, $subscription_key)
 {
     // Store a record of the subscription payment date
     $subscription = self::get_users_subscription($user_id, $subscription_key);
     $subscription['failed_payments'] = $subscription['failed_payments']++;
     self::update_users_subscriptions($user_id, array($subscription_key => $subscription));
     $order = new WC_Order($subscription['order_id']);
     // We've reached the maximum failed payments allowed on the subscription
     if ($subscription['failed_payments'] >= get_option(WC_Subscriptions_Admin::$option_prefix . '_max_failed_payments')) {
         self::cancel_subscription($user_id, $subscription_key);
         $order->cancel_order(__('Maximum number of failed payments reached.', WC_Subscriptions::$text_domain));
         if ('yes' == get_option(WC_Subscriptions_Admin::$option_prefix . '_generate_renewal_order')) {
             WC_Subscriptions_Order::generate_renewal_order($subscription['order_id'], $subscription['product_id']);
         }
     } else {
         // Log payment failure on order
         $order->add_order_note(sprintf(__('Payment failed for subscription %s', WC_Subscriptions::$text_domain), $subscription_key));
     }
     do_action('processed_subscription_payment_failure', $user_id, $subscription_key);
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:27,代码来源:class-wc-subscriptions-manager.php

示例4: elseif

 /**
  *   This is the callback we declared
  *   For sanity we respond HTTP Status 200
  *   You should only print if necesary
  */
 function check_response()
 {
     global $woocommerce;
     global $wpdb;
     error_log("check_response");
     // Load the settings.
     $this->init_settings();
     if ($_POST) {
         error_log("check_response... " . $_POST['action']);
         if ($_POST['action'] === 'openpay_pay_creditcard') {
             $this->openpay_pay_creditcard();
             $order = new WC_Order($_POST["order-id"]);
             $order->update_status('on-hold', 'En espera de pago');
             $order->reduce_order_stock();
             $woocommerce->cart->empty_cart();
             //exit();
             wp_redirect($this->get_return_url($order));
         } elseif ($_POST['action'] === 'openpay_pay_store') {
             $this->openpay_pay_store();
             $order = new WC_Order($_POST["order-id"]);
             $order->update_status('on-hold', 'En espera de pago');
             $order->reduce_order_stock();
             $woocommerce->cart->empty_cart();
             exit;
             wp_redirect($this->get_return_url($order));
         } elseif ($_POST['action'] === 'openpay_pay_transfer') {
             $this->openpay_pay_transfer();
             $order = new WC_Order($_POST["order-id"]);
             $order->update_status('on-hold', 'En espera de pago');
             $order->reduce_order_stock();
             $woocommerce->cart->empty_cart();
             exit;
             wp_redirect($this->get_return_url($order));
         }
     } else {
         header('Content-Type: application/json;charset=utf-8;');
         $data = json_decode(file_get_contents('php://input'));
         $order = new WC_Order($data->transaction->order_id);
         $fetchOption = get_option('openpay_code_private');
         if (update_option('openpay_code_private', $data->verification_code)) {
             $fetchOption2 = " Yes | ";
         } else {
             $fetchOption2 = " No | ";
         }
         $fetchOption2 .= get_option('openpay_code_private');
         $comma_delmited_list = "Response: " . print_r($data, true) . "\n Data:" . print_r($fetchOption, true) . " " . print_r($fetchOption2, true);
         $fp = fopen("array.txt", "a");
         if ($fp == false) {
             //do debugging or logging here
         } else {
             fwrite($fp, $comma_delmited_list);
             fclose($fp);
         }
         if ($data->verification_code) {
             wp_die("Openpay IPN Request Verification Code ->" . $data->verification_code, "Openpay IPN", array('response' => 200));
         } else {
             $status = "";
             $note = "";
             $flag = 0;
             switch ($data->type) {
                 case "charge.succeeded":
                     $order->update_status('processing', "Pago recibido por " . $data->transaction->amount . " id de transacción Openpay " . $data->transaction->id, false);
                     //$order->payment_complete();
                     break;
                 case "charge.cancelled":
                     $order->cancel_order("La orden se cancelo por falta de pago, id Openpay  " . $data->transaction->id);
                     break;
                 case "charge.refunded":
                     $order->add_order_note("El pago se devolcio en Openpay, favor de marcar la orden como cancelada", false);
                     //No se hace nada ya que se tiene que registrar el refund en woocomerce de forma manual
                     break;
             }
             $pays_table = $wpdb->prefix . 'woocommerce_openpay_pays';
             $wpdb->insert($pays_table, array('ID_ORDER' => $data->transaction->order_id, 'ID_OPENPAY_CHARGE' => $data->transaction->id, 'METHOD' => $data->transaction->method, 'STATUS' => $data->transaction->status, 'TYPE' => $data->type, 'CREATED' => $data->event_date), array('%d', '%s', '%s', '%s', '%s'));
             wp_die("Openpay IPN Request Failure", "Openpay IPN", array('response' => 200));
         }
     }
 }
开发者ID:open-pay,项目名称:openpay-woocommerce,代码行数:83,代码来源:woocommerce-openpay.php

示例5: cancel_order

 /**
  * Cancel a pending order.
  */
 public function cancel_order()
 {
     if (isset($_GET['cancel_order']) && isset($_GET['order']) && isset($_GET['order_id'])) {
         $order_key = $_GET['order'];
         $order_id = absint($_GET['order_id']);
         $order = new WC_Order($order_id);
         $user_can_cancel = current_user_can('cancel_order', $order_id);
         $order_can_cancel = in_array($order->status, apply_filters('woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed')));
         $redirect = $_GET['redirect'];
         if ($order->status == 'cancelled') {
             // Already cancelled - take no action
         } elseif ($user_can_cancel && $order_can_cancel && $order->id == $order_id && $order->order_key == $order_key && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce-cancel_order')) {
             // Cancel the order + restore stock
             $order->cancel_order(__('Order cancelled by customer.', 'woocommerce'));
             // Message
             wc_add_notice(apply_filters('woocommerce_order_cancelled_notice', __('Your order was cancelled.', 'woocommerce')), apply_filters('woocommerce_order_cancelled_notice_type', 'notice'));
             do_action('woocommerce_cancelled_order', $order->id);
         } elseif ($user_can_cancel && !$order_can_cancel) {
             wc_add_notice(__('Your order can no longer be cancelled. Please contact us if you need assistance.', 'woocommerce'), 'error');
         } else {
             wc_add_notice(__('Invalid order.', 'woocommerce'), 'error');
         }
         if ($redirect) {
             wp_safe_redirect($redirect);
             exit;
         }
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:31,代码来源:class-wc-form-handler.php

示例6: cancelOrder

 private static function cancelOrder($order_id)
 {
     if (function_exists('wc_get_order')) {
         $order = wc_get_order($order_id);
     } else {
         $order = new WC_Order($order_id);
     }
     $order->cancel_order('Coupon Error');
 }
开发者ID:Giftd,项目名称:giftd-wordpress,代码行数:9,代码来源:giftd.class.php

示例7: explode

 /**
  * PayU Error response
  *
  * @access public
  * @param $_GET
  * @return void
  */
 function payu_error()
 {
     $posted = stripslashes_deep($_GET);
     $order_ref = explode("-", $posted['order_ref']);
     $order_id = $order_ref[0];
     $order = new WC_Order($order_id);
     $order->cancel_order(__('Cancelled payment.', 'wc-payu'));
     wc_add_notice(__('You rejected the payment or the transaction has expired.', 'wc-payu'), 'error');
     if ($this->debug == 'yes') {
         $this->log->add('payu', sprintf(__('Cancelled payment. ID: %s', 'wc-payu'), $order_id));
     }
     $url = $order->get_cancel_order_url();
     wp_redirect($url);
 }
开发者ID:donpapa26,项目名称:bakancslistad,代码行数:21,代码来源:gateway-payu.php


注:本文中的WC_Order::cancel_order方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。