I have foreach which loops through product and create custom add to cart links, for the first time I've got redirected to cart and product was not added to cart, but if I go back to homepage and add to cart any of products through that links it works well. Here is my WP_query:
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post(); ?>
<a href="<?php echo 'https://betlive.cz/?add-to-cart='.get_the_ID(); ?>" class="add_to_cart_button btn btn-outline-primary btn-lg">Přidat do košíku</a>
<?php }
} ?>
I've tried to search for that problem on Google but nothing found. If I had &quantity=1
parameter in add to cart url. I've tried also flush permalinks and reactivate plugins and theme, and this didn't worked up. My version of WooCommerce is 8.5.2.