2016-11-02 6 views
1

プラグインによって作成された関数で3行を修正する必要があります。私は上記のコードの途中でコメントアウト行を削除したいこのWordPressプラグイン機能をアクション/フィルターフックで変更できますか?

/** 
     * function to modify order_items of renewal order 
     * 
     * @param array $order_items 
     * @param int $original_order_id 
     * @param int $renewal_order_id 
     * @param int $product_id 
     * @param string $new_order_role 
     * @return array $order_items 
     */ 
     public function sc_subscriptions_renewal_order_items($order_items = null, $original_order_id = 0, $renewal_order_id = 0, $product_id = 0, $new_order_role = null) { 


      $is_subscription_order = wcs_order_contains_subscription($original_order_id); 

      if ($is_subscription_order) { 
       $return = false; 
      } else { 
       $return = true; 
      } 
      if ($return) { 
       return $order_items; 
      } 

      $pay_from_credit_of_original_order = get_option('pay_from_smart_coupon_of_original_order', 'yes'); 

      if ($pay_from_credit_of_original_order != 'yes') return $order_items; 
      if ($new_order_role != 'child') return $order_items; 
      if (empty($renewal_order_id) || empty($original_order_id)) return $order_items; 

      $original_order = $this->get_order($original_order_id); 
      $renewal_order = $this->get_order($renewal_order_id); 

      $coupon_used_in_original_order = $original_order->get_used_coupons(); 
      $coupon_used_in_renewal_order = $renewal_order->get_used_coupons(); 

      if (sizeof($coupon_used_in_original_order) > 0) { 
       $smart_coupons_contribution = array(); 
       foreach ($coupon_used_in_original_order as $coupon_code) { 
        $coupon = new WC_Coupon($coupon_code); 
        if (! empty($coupon->discount_type) && $coupon->discount_type == 'smart_coupon' && ! empty($coupon->amount) && ! in_array($coupon_code, $coupon_used_in_renewal_order, true)) { 
         $renewal_order_total = $renewal_order->get_total(); 

         /* ************ 
         THE BELOW 3 LINES ARE WHAT I NEED TO REMOVE 
         **************** */ 
         if ($coupon->amount < $renewal_order_total) { 
          continue; 
         } 
         /* ************ 
         THE ABOVE 3 LINES ARE WHAT I NEED TO REMOVE 
         **************** */ 

         $discount = min($renewal_order_total, $coupon->amount); 
         if ($discount > 0) { 
          $new_order_total = $renewal_order_total - $discount; 
          update_post_meta($renewal_order_id, '_order_total', $new_order_total); 
          update_post_meta($renewal_order_id, '_order_discount', $discount); 
          if ($new_order_total <= floatval(0)) { 
           update_post_meta($renewal_order_id, '_renewal_paid_by_smart_coupon', 'yes'); 
          } 
          $renewal_order->add_coupon($coupon_code, $discount); 
          $smart_coupons_contribution[ $coupon_code ] = $discount; 
          $used_by = $renewal_order->get_user_id(); 
          if (! $used_by) { 
           $used_by = $renewal_order->billing_email; 
          } 
          $coupon->inc_usage_count($used_by); 
         } 
        } 
       } 
       if (! empty($smart_coupons_contribution)) { 
        update_post_meta($renewal_order_id, 'smart_coupons_contribution', $smart_coupons_contribution); 
       } 
      } 

      return $order_items; 
     } 

:ここ

が本来の機能である(アスタリスクで強調途中で私のコメントセクション、探してください):

コアプラグインコードを編集する必要がありますか?これらの行を変更する独自の関数を記述できますか?

ご協力いただきありがとうございます。

答えて

関連する問題