• Resolved Beno?t

    (@dafray31)


    Hello,

    I’m contacting you about Woocommerce Box Office. I have problem:

    – I use a form to add products in Woocommerce, using the standard code to add products in woocommerce it works. But for the tickets, although the products are well added, at the end of the payment (validated) tickets do not appear (barcode dosent exist). And as if the customer had not purchased a ticket.

    Other parameters probably need to be passed? Here’s my code (I only have one field, “email”). There’s nothing written in the documentation


    $quantity_plein = isset($fields["form-field-hsynnx"])
    ? intval($fields["form-field-hsynnx"])
    : 0;
    $quantity_reduit = isset($fields["form-field-aliusd"])
    ? intval($fields["form-field-aliusd"])
    : 0;
    $quantity_gratuit = isset($fields["form-field-cvmmpf"])
    ? intval($fields["form-field-cvmmpf"])
    : 0;

    $product_quantities = [
    5063 => $quantity_plein,
    5065 => $quantity_reduit,
    5066 => $quantity_gratuit,
    ];

    foreach ($product_quantities as $product_id => $quantity) {
    if ($quantity > 0) {
    $product = wc_get_product($product_id);
    WC()->cart->add_to_cart($product->get_id(), $quantity);
    }
    }

    • This topic was modified 1 year, 5 months ago by .
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Php code to add to cart product tickets from Woo Box Office’ is closed to new replies.