| @@ 1173-1194 (lines=22) @@ | ||
| 1170 | /** |
|
| 1171 | * Add order fee via ajax. |
|
| 1172 | */ |
|
| 1173 | public static function add_order_fee() { |
|
| 1174 | check_ajax_referer( 'order-item', 'security' ); |
|
| 1175 | ||
| 1176 | if ( ! current_user_can( 'edit_shop_orders' ) ) { |
|
| 1177 | die( -1 ); |
|
| 1178 | } |
|
| 1179 | ||
| 1180 | $order_id = absint( $_POST['order_id'] ); |
|
| 1181 | $order = wc_get_order( $order_id ); |
|
| 1182 | ||
| 1183 | if ( $order ) { |
|
| 1184 | $order_taxes = $order->get_taxes(); |
|
| 1185 | $item = new WC_Order_Item_Fee(); |
|
| 1186 | ||
| 1187 | $item->set_order_id( $order->get_id() ); |
|
| 1188 | $item->save(); |
|
| 1189 | ||
| 1190 | include( 'admin/meta-boxes/views/html-order-fee.php' ); |
|
| 1191 | } |
|
| 1192 | ||
| 1193 | die(); |
|
| 1194 | } |
|
| 1195 | ||
| 1196 | /** |
|
| 1197 | * Add order shipping cost via ajax. |
|
| @@ 1226-1247 (lines=22) @@ | ||
| 1223 | /** |
|
| 1224 | * Add order tax column via ajax. |
|
| 1225 | */ |
|
| 1226 | public static function add_order_tax() { |
|
| 1227 | check_ajax_referer( 'order-item', 'security' ); |
|
| 1228 | ||
| 1229 | if ( ! current_user_can( 'edit_shop_orders' ) ) { |
|
| 1230 | die( -1 ); |
|
| 1231 | } |
|
| 1232 | ||
| 1233 | $order_id = absint( $_POST['order_id'] ); |
|
| 1234 | $order = wc_get_order( $order_id ); |
|
| 1235 | ||
| 1236 | if ( $order ) { |
|
| 1237 | $item = new WC_Order_Item_Tax(); |
|
| 1238 | ||
| 1239 | $item->set_rate_id( absint( $_POST['rate_id'] ) ); |
|
| 1240 | $item->set_order_id( $order->get_id() ); |
|
| 1241 | $item->save(); |
|
| 1242 | ||
| 1243 | include( 'admin/meta-boxes/views/html-order-items.php' ); |
|
| 1244 | } |
|
| 1245 | ||
| 1246 | die(); |
|
| 1247 | } |
|
| 1248 | ||
| 1249 | /** |
|
| 1250 | * Remove an order item. |
|