/** * Triggered when adding an item in the backend. * * If deposits are forced, set all meta data. */ public function ajax_add_order_item_meta($item_id, $item) { if (WC_Deposits_Product_Manager::deposits_forced($item['product_id'])) { $product = wc_get_product(absint($item['variation_id'] ? $item['variation_id'] : $item['product_id'])); woocommerce_add_order_item_meta($item_id, '_is_deposit', 'yes'); woocommerce_add_order_item_meta($item_id, '_deposit_full_amount', $item['line_total']); woocommerce_add_order_item_meta($item_id, '_deposit_full_amount_ex_tax', $item['line_total']); if ('plan' === WC_Deposits_Product_Manager::get_deposit_type($item['product_id'])) { $plan_id = current(WC_Deposits_Plans_Manager::get_plan_ids_for_product($item['product_id'])); woocommerce_add_order_item_meta($item_id, '_payment_plan', $plan_id); } else { $plan_id = 0; } // Change line item costs $deposit_amount = WC_Deposits_Product_Manager::get_deposit_amount($product, $plan_id, 'order', $item['line_total']); wc_update_order_item_meta($item_id, '_line_total', $deposit_amount); wc_update_order_item_meta($item_id, '_line_subtotal', $deposit_amount); } }
?> " /><label for="wc-deposits-payment-plan-<?php echo esc_attr($plan->get_id()); ?> "> <strong class="wc-deposits-payment-plan-name"><?php echo esc_html($plan->get_name()); ?> </strong> <small class="wc-deposits-payment-plan-description"><?php echo wp_kses_post($plan->get_description()); ?> </small> </label> </li> <?php } ?> </ul> <?php } else { ?> <div class="wc-deposits-payment-description"> <?php echo WC_Deposits_Product_Manager::get_formatted_deposit_amount($post->ID); ?> </div> <?php } ?> </div>