Support

Account

Forum Replies Created

  • Solved by placing everything inside the loop.

    
    $current_date = strtotime(date('Y-m-d H:i:s'));
        if(have_rows('theme_free_products', 'options')){
            while(have_rows('theme_free_products', 'options')){
                the_row();
                $start_date = get_sub_field('start_date');
                $end_date = get_sub_field('end_date');
                if(strtotime($start_date) <= $current_date && strtotime($end_date) > $current_date){
                    $product_id = get_sub_field('product', false);
    				$productextra    = wc_get_product( $product_id );
    				$new_product_price = 0;
    				$productextra->set_price( $new_product_price );   
    				$item_id    = $order->add_product( $productextra );             
                    
                }
            }
        }
    
    
  • Thanks again, this doesnt work unfortunately. And I dont want an if or else statement, I want to output the data from the selected select fields which already has information (either text field or a post object).

  • Thanks John. For the first one it would work, I can just add my html in the if statement.

    But the second one – it has Post object set to products, so there I need to call the selected product. (link and thumb)

Viewing 3 posts - 1 through 3 (of 3 total)