php - Woocommerce packages -
customers can dynamically add own inscription / message each product. each product sent individually (with shipping applied). on cart page, have built interface customer can enter address next each line item (item in cart).
i have used filter create packages. logging out content of packages, see each product package - , package contains dynamically created custom fields. package contains data need.
[i have removed isset stuff make easier read]
<!-- language: lang-php --> add_filter( 'woocommerce_cart_shipping_packages','filter_woocommerce_cart_shipping_packages', 10, 1 ); function filter_woocommerce_cart_shipping_packages( $packages ) { // reset packages $packages = array(); foreach ( wc()->cart->get_cart() $key => $item ) { $packages[] = array( 'contents' => array($key => $item), 'contents_cost' => $item['line_total'], 'applied_coupons' => wc()->cart->applied_coupons, 'user' => array( 'id' => get_current_user_id(), ), 'destination' => array( 'country' => $item['country'], 'state' => $item['state'], 'postcode' => $item['postcode'], 'city' => $item['city'], 'address' => $item['address'], 'address_2' => $item['address_2'], ) ); } return $packages; }
on cart page, have each packaged listed - customer able choose different shipping per package , check out:
however, absolutely none of package information available on backend. cannot see of dynamic data - available in $package['contents'].
i have been advised need save order cart data? unable find example of this.
Comments
Post a Comment