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


PHP WC_Order::needs_payment方法代码示例

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


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

示例1: WX_Loop_Order_Status

 public function WX_Loop_Order_Status()
 {
     //ajax loop
     Log::DEBUG(' start loop !');
     $order_id = $_GET['orderId'];
     $order = new WC_Order($order_id);
     $isPaid = !$order->needs_payment();
     Log::DEBUG(" check_wechatpay_response orderid:" . $order_id . "is need pay:" . $isPaid);
     if ($isPaid) {
         $returnUrl = urldecode($this->get_return_url($order));
         echo json_encode(array('status' => 'paid', 'message' => $returnUrl));
     } else {
         echo json_encode(array('status' => 'nPaid', 'message' => 'nPaid'));
     }
     die('');
 }
开发者ID:zhuhank,项目名称:wechat-payment-for-woocommerce,代码行数:16,代码来源:class-wc-wechatpay.php

示例2: orderNeedsPayment

 /**
  * @param WC_Order $order
  * @return bool
  */
 protected function orderNeedsPayment(WC_Order $order)
 {
     if ($order->needs_payment()) {
         return true;
     }
     // Has initial order status 'on-hold'
     if ($this->getInitialOrderStatus() === self::STATUS_ON_HOLD && Mollie_WC_Plugin::getDataHelper()->hasOrderStatus($order, self::STATUS_ON_HOLD)) {
         return true;
     }
     return false;
 }
开发者ID:vanengers,项目名称:WooCommerce,代码行数:15,代码来源:abstract.php

示例3:

 /**
  * Test: needs_payment
  */
 function test_needs_payment()
 {
     $object = new WC_Order();
     $object->set_status('pending');
     $this->assertFalse($object->needs_payment());
     $object->set_total(100);
     $this->assertTrue($object->needs_payment());
     $object->set_status('processing');
     $this->assertFalse($object->needs_payment());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:13,代码来源:crud.php

示例4: pay_action

 /**
  * Process the pay form.
  */
 public function pay_action()
 {
     global $wp;
     if (isset($_POST['woocommerce_pay']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-pay')) {
         ob_start();
         // Pay for existing order
         $order_key = $_GET['key'];
         $order_id = absint($wp->query_vars['order-pay']);
         $order = new WC_Order($order_id);
         if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed'))) {
             // Set customer location to order location
             if ($order->billing_country) {
                 WC()->customer->set_country($order->billing_country);
             }
             if ($order->billing_state) {
                 WC()->customer->set_state($order->billing_state);
             }
             if ($order->billing_postcode) {
                 WC()->customer->set_postcode($order->billing_postcode);
             }
             if ($order->billing_city) {
                 WC()->customer->set_city($order->billing_city);
             }
             // Update payment method
             if ($order->needs_payment()) {
                 $payment_method = wc_clean($_POST['payment_method']);
                 $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
                 // Update meta
                 update_post_meta($order_id, '_payment_method', $payment_method);
                 if (isset($available_gateways[$payment_method])) {
                     $payment_method_title = $available_gateways[$payment_method]->get_title();
                 }
                 update_post_meta($order_id, '_payment_method_title', $payment_method_title);
                 // Validate
                 $available_gateways[$payment_method]->validate_fields();
                 // Process
                 if (wc_notice_count('error') == 0) {
                     $result = $available_gateways[$payment_method]->process_payment($order_id);
                     // Redirect to success/confirmation/payment page
                     if ('success' == $result['result']) {
                         wp_redirect($result['redirect']);
                         exit;
                     }
                 }
             } else {
                 // No payment was required for order
                 $order->payment_complete();
                 wp_safe_redirect($order->get_checkout_order_received_url());
                 exit;
             }
         }
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:56,代码来源:class-wc-form-handler.php

示例5: 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);
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:29,代码来源:class-wc-subscription.php

示例6: validate_transaction_response

 /**
  * Validate a transaction response.
  *
  * @since 4.3.0
  * @param \WC_Order $order the order object
  * @param \SV_WC_Payment_Gateway_API_Payment_Notification_Response the response object
  * @throws \SV_WC_Payment_Gateway_Exception
  */
 protected function validate_transaction_response($order, $response)
 {
     // If the order is invalid, bail
     if (!$order || !$order->id) {
         throw new SV_WC_Payment_Gateway_Exception(sprintf(__('Could not find order %s', 'woocommerce-plugin-framework'), $response->get_order_id()));
     }
     // If the order has already been completed, bail
     if (!$order->needs_payment()) {
         /* translators: Placeholders: %s - payment gateway title (such as Authorize.net, Braintree, etc) */
         $order->add_order_note(sprintf(esc_html__('%s duplicate transaction received', 'woocommerce-plugin-framework'), $this->get_method_title()));
         throw new SV_WC_Payment_Gateway_Exception(sprintf(__('Order %s is already paid for.', 'woocommerce-plugin-framework'), $order->get_order_number()));
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:21,代码来源:class-sv-wc-payment-gateway-hosted.php

示例7: woocommerce_pay_action

/**
 * Process the pay form.
 *
 * @access public
 * @return void
 */
function woocommerce_pay_action()
{
    global $woocommerce;
    if (isset($_POST['woocommerce_pay']) && $woocommerce->verify_nonce('pay')) {
        ob_start();
        // Pay for existing order
        $order_key = urldecode($_GET['order']);
        $order_id = absint($_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'))) {
            // Set customer location to order location
            if ($order->billing_country) {
                $woocommerce->customer->set_country($order->billing_country);
            }
            if ($order->billing_state) {
                $woocommerce->customer->set_state($order->billing_state);
            }
            if ($order->billing_postcode) {
                $woocommerce->customer->set_postcode($order->billing_postcode);
            }
            if ($order->billing_city) {
                $woocommerce->customer->set_city($order->billing_city);
            }
            // Update payment method
            if ($order->needs_payment()) {
                $payment_method = woocommerce_clean($_POST['payment_method']);
                $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
                // Update meta
                update_post_meta($order_id, '_payment_method', $payment_method);
                if (isset($available_gateways[$payment_method])) {
                    $payment_method_title = $available_gateways[$payment_method]->get_title();
                }
                update_post_meta($order_id, '_payment_method_title', $payment_method_title);
                // Validate
                $available_gateways[$payment_method]->validate_fields();
                // Process
                if ($woocommerce->error_count() == 0) {
                    $result = $available_gateways[$payment_method]->process_payment($order_id);
                    // Redirect to success/confirmation/payment page
                    if ($result['result'] == 'success') {
                        wp_redirect($result['redirect']);
                        exit;
                    }
                }
            } else {
                // No payment was required for order
                $order->payment_complete();
                wp_safe_redirect(get_permalink(woocommerce_get_page_id('thanks')));
                exit;
            }
        }
    }
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:59,代码来源:woocommerce-functions.php


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