You need to explode the comma separated string to get the array of IDs. Follow the below code.
$cookie_array = $_COOKIE["your-results"];
// Test output
echo $cookie_array;
$cookie_array = array_map( 'absint', (array) explode(',', $cookie_array) );
$sug_args = array(
'post_type' => 'product',
'post__in' => $cookie_array,
);
$sug_query = new WP_query ($sug_args);
if( $sug_query->have_posts() ) :
while( $sug_query->have_posts() ) :
$sug_query->the_post();
// Run Loop
wc_get_template_part( 'content', 'product' );
endwhile;
endif;
wp_reset_query();
Related Posts:
- retrieve thumbnail from post ID of best selling product in category
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Display related products with custom output
- How can I use wp_query to show all product data using just the products ID?
- Display a specific category of products in shop page and disable code for specific actions
- How to store post ID’s in cookie or session to display the same posts later
- How to display SQL query that ran in WC_Order_Query?
- WP_Query multiple post results
- WordPress WP_Query without query GET parameters
- Output product category link from WP_Query
- How to work Woocommerce pagination inside shortcode?
- WP_Query for woocommerce products with a pattern as a post_title
- IF statement not working – Any suggestions?
- get_filtered_term_product_counts – Get product terms if any products
- WP_Query To Display Product Of Brand On Taxonomy Page
- Woocommerce Related Product by 2 taxonomy
- wp_query beginner
- WooCommerce – Print Processing orders [closed]
- Use WP_Query Data In Cookie
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- WooCommerce Related Products by Attribute
- Image as Sales Badge
- How to query for posts with a null or blank post_name?
- WordPress pagination not working with search page
- get current custom post ID by WP_Query method
- WooCommerce – Email admin with new user details
- How to Highlight unread WordPress posts?
- Automatically remove a canceled order in Woocommerce
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Using foreach loop breaks
- Create WP_Query to search for posts by their categories or their parent/child categories
- Call global variable array() in woocommerce child/template
- WP Query with custom Shortcode
- wp_query with cat not working
- Remove price from Woocommerce variable product dropdown menu
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- How to use an associative array in post__in with WP_Query?
- Adding nofollow to a PHP generated Nav
- If Query In Sidebar
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Compare post-IDs within WP_Query? (Less than / Greater than)
- Why is my cookie not unsetting upon logout? [closed]
- How to combine wordpress_logged_in cookies in one cookie?
- Automated Cart Update With Alert Box Each Time
- Two Different Links for Same Product – WooCommerce [closed]
- Issue adding sub category programmatically
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to use $query->set with post__in?
- dividing sub-categories by parent category – WordPress
- Show prices with tax in Woocommerce Mini Cart [closed]
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Woocommerce product variation backorder
- Status 400 for AJAX POST Request with admin-ajax.php
- Problem with custom plugin using AJAX to pull info from php file
- Woocommerce hook run after an Order been created through REST API
- How can I apply_filters from inside a function?
- Get and insert order email address to the PHP template inside HTML text
- Modify HTML structure of fields in woocommerce checkout form
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Loading the same WP_Query in two different wordpress .php templates
- Auto-update products after they were published – Woocommerce
- How to prevent WP_Query function from returning all posts when empty?
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Reload part of checkout on changed shipping method
- Dynamic content based on a URL parameter
- How to get all shipping rates and costs without session in woocommerce?
- If no products are on sale – hide ID or class
- Woocommerce related product text
- Woocommerce api: create product with images – bad request
- Trying to build simple deposit code that hooks into woocommerce
- WooCommerce Webhooks not firing because of error in wp-includes/meta.php
- Different Minimum Order Amounts based on Shipping Zone [closed]
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- do search in two site and show the result in first site
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Add a product to checkout via form
- Trying to place a custom field after the total section in the checkout page in woocommerce
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Which field should I edit to make the checkbox marked by default?
- Displaying Woocommerce Product Category in WordPress
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- Add more button if more 8 items
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- wordpress + woocommerce display product with additional information [closed]
- how to fix error “called incorrectly, should not be accessed directly”?
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- How to auto fetch customer details in Woocommerce in checkout page
- Displaying custom taxonomy on WooCommerce product page
- Sum the total amount of a specific product purchased per user and display in table
- WordPress, AJAX and pre_get_posts using conditional tags
- how can i use $_COOKIE[] + PostID to execute the below code?
- Change “add to cart” button color based on Woocommerce product category [closed]
- How can I get the values of my WordPress $wpdb query in Jquery?
- Get users that likes the post
- How can I pass a custom/dynamic product to the Woocommerce cart?
- Add to cart function not working for first product when cart is empty [closed]
- I want to add custom add to cart link [closed]
- How to make products with no cost in WooCommerce
- Woocommerce : Can’t get product info in loop
- WooCommerce custom product dimensions