• Hi,
    We are trying to add a product by url or via the function WC()->cart->add_to_cart.

    – So, firstly by url we need to know how to pass the date. We tried with this variable: “start_date=2018-07-13” but it’s not working.
    (Sample >> ?add-to-cart=707&variation_id=2137&attribute_pa_person=adults&attribute_pa_hours=2-hrs-trip-at-400-pm-only-friday&start_date=2018-07-13)

    – Similar to this, we need to add another product with the same date selected for the current product. But how to pass the date in this kind of function??

    $product_id = $product->get_id();
    $quantity = 1;
    $variation_id = 2138;
    $variation = array(
    ‘Person’ => ‘Children’,
    ‘Hours’ => ‘2 Hours’,
    );
    $easy_booking_date = (((how to get current selection????)))
    WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, ???);

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Plugin Author Ashanna

    (@morki)

    Hello,

    For the first thing, maybe try _ebs_start and _ebs_end. I’m not sure though, they are not added as regular variations.

    For the second question, dates are stored in the session. Try this:

    $booking_session = WC()->session->get( 'booking' );
    $start = $booking_session[$product_id]['start'];
    $end = $booking_session[$product_id]['end'];

    Again, I’m not sure it is going to work, but that’s pretty much all I can tell you.

Viewing 1 replies (of 1 total)
  • The topic ‘Pass date variable via URL + Get current date selection’ is closed to new replies.