how to handle multiple forloop?

You can do something like this public function getStuffDone() { $order_ids = array( 358,368 ); $items = array(); // contains the names foreach ( $order_ids as $order_id ) { $order = wc_get_order( $order_id ); foreach ( $order->get_items() as $item_values ) { $items[ $order_id ][] = $item_values->get_name(); // add the name to the array } } … Read more

Masking external links with internal link for member-only

You will want to add the hook function in your functions.php file: $user = wp_get_current_user(); if($user->exists) { add_filter(‘public_link_root’, function() { return ‘example.com’; } ); } Then whenever you are working with a URL in any of your template files, you can allow the URL to be modified by your customer filter public_link_root. The filter will … Read more

WP_Query and DES sort for Custom Taxonomy based upon a meta field?

Nothing. You shouldn’t need to set the post type. Your taxonomy archive is presumably already querying the correct post type. function customize_customtaxonomy_archive_display ( $query ) { if ( $query->is_tax( ‘country’ ) ) { $query->set( ‘meta_key’, ‘start_date’ ); $query->set( ‘orderby’, ‘meta_value_num’ ); $query->set( ‘order’, ‘ASC’ ); } } Note: $query->is_main_query() is redundant when checking $query->is_tax(), because … Read more

Woocommerce – Shipping tax class based on cart items not using the highest tax available

I have found the answer by override the shipping tax filter // 0% and 21% tax producdts added combined to the cart needs to have 21% shipping tax add_filter(‘woocommerce_shipping_packages’, ‘override_woocommerce_shipping_packages’); function override_woocommerce_shipping_packages($packages) { $shipment_needs_tax = false; foreach ($packages[0][‘contents’] as $cartitem) { if (!empty($cartitem[‘data’]->tax_class)) $shipment_needs_tax = true; } if ($shipment_needs_tax && empty($packages[0][‘rates’][‘flat_rate:3’]->get_taxes())) { $shipcost = $packages[0][‘rates’][‘flat_rate:3’]->get_cost(); … Read more