I'm creating a custom endpoint, that's basically this:
register_rest_route( 'wc/v3', '/custom-product-list(?:/(&P<custom_page>\d+))?(?:/(?P<custom_colors>\d+))?', array(
'method' => 'GET',
'callback' => 'custom_product_list',
'args' => [
'custom_page',
'custom_colors'
],
));
What am trying to achieve is this: website.com/shop?page=2&colors=red,green,blue You know, like a normal URL that you can add stuff to it, and also have these things optional.
This however, doesn't work.
I decode it like this:
function custom_product_list( $args ) {
global $product;
$offset = 0;
$limit = 9;
$page = $args['custom_page'];
$colors = $args['custom_colors'];
How should I go about doing this?