@@ 146-166 (lines=21) @@ | ||
143 | $found_shipping_classes = $this->find_shipping_classes( $package ); |
|
144 | $highest_class_cost = 0; |
|
145 | ||
146 | foreach ( $found_shipping_classes as $shipping_class => $products ) { |
|
147 | // Also handles BW compatibility when slugs were used instead of ids |
|
148 | $shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' ); |
|
149 | $class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' ); |
|
150 | ||
151 | if ( $class_cost_string === '' ) { |
|
152 | continue; |
|
153 | } |
|
154 | ||
155 | $has_costs = true; |
|
156 | $class_cost = $this->evaluate_cost( $class_cost_string, array( |
|
157 | 'qty' => array_sum( wp_list_pluck( $products, 'quantity' ) ), |
|
158 | 'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ) |
|
159 | ) ); |
|
160 | ||
161 | if ( $this->type === 'class' ) { |
|
162 | $rate['cost'] += $class_cost; |
|
163 | } else { |
|
164 | $highest_class_cost = $class_cost > $highest_class_cost ? $class_cost : $highest_class_cost; |
|
165 | } |
|
166 | } |
|
167 | ||
168 | if ( $this->type === 'order' && $highest_class_cost ) { |
|
169 | $rate['cost'] += $highest_class_cost; |
@@ 164-184 (lines=21) @@ | ||
161 | $found_shipping_classes = $this->find_shipping_classes( $package ); |
|
162 | $highest_class_cost = 0; |
|
163 | ||
164 | foreach ( $found_shipping_classes as $shipping_class => $products ) { |
|
165 | // Also handles BW compatibility when slugs were used instead of ids |
|
166 | $shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' ); |
|
167 | $class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' ); |
|
168 | ||
169 | if ( $class_cost_string === '' ) { |
|
170 | continue; |
|
171 | } |
|
172 | ||
173 | $has_costs = true; |
|
174 | $class_cost = $this->evaluate_cost( $class_cost_string, array( |
|
175 | 'qty' => array_sum( wp_list_pluck( $products, 'quantity' ) ), |
|
176 | 'cost' => array_sum( wp_list_pluck( $products, 'line_total' ) ) |
|
177 | ) ); |
|
178 | ||
179 | if ( $this->type === 'class' ) { |
|
180 | $rate['cost'] += $class_cost; |
|
181 | } else { |
|
182 | $highest_class_cost = $class_cost > $highest_class_cost ? $class_cost : $highest_class_cost; |
|
183 | } |
|
184 | } |
|
185 | ||
186 | if ( $this->type === 'order' && $highest_class_cost ) { |
|
187 | $rate['cost'] += $highest_class_cost; |