Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Convenience methods for other plugins to easily get add-ons for a given
- * order
- *
- * @since 1.0
- * @param int $order_id WC_Order ID
- * @return array of WC_Checkout_Add_On objects
- */
- public function get_order_add_ons($order_id)
- {
- $order = SV_WC_Plugin_Compatibility::wc_get_order($order_id);
- $add_ons = get_option('wc_checkout_add_ons', array());
- $order_add_ons = array();
- foreach ($order->get_items('fee') as $fee_id => $fee) {
- // bail for fees that aren't add-ons or deleted add-ons
- if (empty($fee['wc_checkout_add_on_id']) || !isset($add_ons[$fee['wc_checkout_add_on_id']])) {
- continue;
- }
- $add_on = new WC_Checkout_Add_On($fee['wc_checkout_add_on_id'], $add_ons[$fee['wc_checkout_add_on_id']]);
- $order_add_ons[$fee['wc_checkout_add_on_id']] = array('name' => $add_on->name, 'checkout_label' => $add_on->label, 'value' => $fee['wc_checkout_add_on_value'], 'normalized_value' => maybe_unserialize($fee['wc_checkout_add_on_label']), 'total' => $fee['line_total'], 'total_tax' => $fee['line_tax'], 'fee_id' => $fee_id);
- }
- return $order_add_ons;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement