SHARE
TWEET

Untitled

a guest Jun 26th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   * Convenience methods for other plugins to easily get add-ons for a given
  3.   * order
  4.   *
  5.   * @since 1.0
  6.   * @param int $order_id WC_Order ID
  7.   * @return array of WC_Checkout_Add_On objects
  8.   */
  9.  public function get_order_add_ons($order_id)
  10.  {
  11.      $order = SV_WC_Plugin_Compatibility::wc_get_order($order_id);
  12.      $add_ons = get_option('wc_checkout_add_ons', array());
  13.      $order_add_ons = array();
  14.      foreach ($order->get_items('fee') as $fee_id => $fee) {
  15.          // bail for fees that aren't add-ons or deleted add-ons
  16.          if (empty($fee['wc_checkout_add_on_id']) || !isset($add_ons[$fee['wc_checkout_add_on_id']])) {
  17.              continue;
  18.          }
  19.          $add_on = new WC_Checkout_Add_On($fee['wc_checkout_add_on_id'], $add_ons[$fee['wc_checkout_add_on_id']]);
  20.          $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);
  21.      }
  22.      return $order_add_ons;
  23.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top