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;
}
: 여기
는 원래의 함수이다 (별표에 의해 강조 중간에 내 주석 섹션을 찾아)코어 플러그인 코드를 수정하지 않고이를 수행 할 수있는 방법이 있습니까? 해당 줄을 바꾸기 위해 자체 함수를 작성할 수 있습니까?
제공 할 수있는 도움에 감사드립니다.