<?php

/**

 * Plugin Name: POP Cats – Hide Bundle Containers from Legacy REST API

 * Description: Removes WooCommerce Product Bundles container line items from

 *              Legacy REST API (v3) order responses so the AMSCO/ShipHero

 *              integration imports only the pickable child items.

 *              The modern REST API (/wp-json/) used by Shippo, Zoho, etc.

 *              is completely untouched — this hook only exists in the

 *              Legacy API request lifecycle.

 * Author:      POP Cats

 * Version:     1.0.0

 */


defined( 'ABSPATH' ) || exit;


add_filter( 'woocommerce_api_order_response', function ( $order_data, $order ) {


// Bail early if Product Bundles isn't active, the response has no

// line items, or we didn't receive a proper order object.

if (

! function_exists( 'wc_pb_is_bundle_container_order_item' )

|| empty( $order_data['line_items'] )

|| ! $order instanceof WC_Order

) {

return $order_data;

}


$order_items = $order->get_items();


$order_data['line_items'] = array_values( array_filter(

$order_data['line_items'],

function ( $line_item ) use ( $order_items, $order ) {


$item_id = isset( $line_item['id'] ) ? (int) $line_item['id'] : 0;


// Keep anything we can't positively identify.

if ( ! $item_id || ! isset( $order_items[ $item_id ] ) ) {

return true;

}


// Drop bundle container rows (e.g. "Case of 4"); keep everything else.

return ! wc_pb_is_bundle_container_order_item( $order_items[ $item_id ], $order );

}

) );


return $order_data;

}, 10, 2 );

https://popcats.co/post-sitemap.xml 2024-11-24T13:50:36+00:00 https://popcats.co/page-sitemap.xml 2026-07-31T15:27:44+00:00 https://popcats.co/jet-woo-builder-sitemap.xml 2026-06-26T10:33:58+00:00 https://popcats.co/product-sitemap.xml 2026-08-03T07:14:09+00:00 https://popcats.co/category-sitemap.xml 2024-11-24T13:50:36+00:00 https://popcats.co/local-sitemap.xml 2026-08-04T06:49:13+00:00