Change quantity PHP

Can I please have an example of how to change the quantity of an item (SLIP) in the Session?  I am using the PHP SDK and do not understand how to send the alter array as the API documentation describes.  Thanks!

Comments

  • MitchMitch Checkfront
    edited September 2016
    Hi kg567,

    Thanks for reaching out!

    Here's an example of how you could modify the quantity (parameter ID) of an item using the PHP SDK.

    $qty = 5;
    $data = [   
       'date' => $date,
       'item_id' => $item_to_book,
       'param' => [
          'qty' => $qty
       ]
    ];
    $response = $this->checkfront->get('item', $data );


    Hopefully this helps. Please let us know if you have any other questions.

    Cheers,
    Mitch
    Checkfront support team

  • Thanks, this helped!
  • edited November 2016
    I am trying the following code to no luck...can you please let me know where the error is occuring?

    $url = "session_id=$sessionid&alter[$line_id]=$qty";
    $Booking->set('booking/session/', $url);

    On the API docs it says to use the alter array.  Am I not doing this correctly?  I am trying to change the quantity of an item that has already been added to the session.
  • MitchMitch Checkfront
    Hi kg567,

    If I were to set the booking session I'd do something like this:

    public function session( $slip ) {
    $data = [
    'slip' => $slip
    ];
    $session = $this->checkfront->post('booking/session', $data );
    return $session['booking']['session']['id'];
    }

    Hopefully this helps!

    Cheers,
    Mitch
    Checkfront support team

  • I have already set the slip in the session.  Is there a way to just change the quantity that the slip contains without sending another slip?
  • edited February 18
    @Mitch I'm experiencing the same issue with setting item quantity. Can you please provide php example to set quatity.
    That is how I try it now.
    $slip = $response['item']['rate']['slip'];
    if($slip){
    $response = $checkfront->post('booking/session', [
    'slip' => [$slip]
    ]);
    $session = $response['booking']['session']['id'];
    if($session){
    $checkfront->set_session($session,$response['booking']['session']);
    $response = $checkfront->post('booking/session', [
    'alter' => [
    1 => 3
    ]
    ]);
    Obviously 1 is index of item added in first session call. Tried adding session_id as parameter to second post request, but had no luck.
    "item": {
                    "1": {
                        "sku": "verzendingenterugsturenviagls",
                        "item_id": 62,
                        "slip": "62.20190313X6-aantallevering.1",
                        "available": 1000000000
                    }
                }
    There is reference to some line_id parameter in docs, but I don't see it in response.
    I found old post about items with simple pricing are allowed to set quantity, but can't find where can I check if item is simple pricing or not in UI or API.
Sign In or Register to comment.