• Resolved neoinwales

    (@neoinwales)


    Hi,
    I am using City Tour theme integrated with WooCommerce to process bookings. The maximum cap set up for each tour doesn’t work if many people are booking at the same time (not exact same time, seconds difference but within a minute). As a result, it can be become over booked.
    I hired a developer to add a calendar to replace the theme’s own simple calendar. I can set up the maximum number in the new calendar for each day (tour). But, the developer said it is the theme which has the fault, not the plugin he developed. It looks to me it is the plugin’s problem, not the theme, as maximum number now is set up in the new calendar, not by the theme’s own back-end tour setting. But, I cannot rule out whether WooCommerce has such an issue when processing orders at same time. So, I raise this issue and hope you can help, or at least point out the right direction which I can follow.
    Many thanks,
    Neo

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Linda

    (@lindamork)

    Automattic Happiness Engineer

    Hi there,

    It sounds like this is more a matter between your plugin developer and your theme. If you’ve set product inventory levels for the number of bookings that can be made for that product, inventory will be reduced when it’s added to the cart. The amount of time it can stay in the cart, and therefore unavailable to other customers, depends upon your Hold Stock time setting in WooCommerce > Settings > Products > Inventory. However, your theme and the plugin may have altered the way this works in WooCommerce which is why it’s likely an issue between the plugin and your theme which needs to be resolved.

    Thread Starter neoinwales

    (@neoinwales)

    Hi Linda,
    I have this reply from the theme developer below –
    “you are using woocommerce payment in CityTours theme. If customers book a tour or a hotel, it will be added to woocommerce cart and it will stay before customer remove it in the cart. So it is not issue.”
    I guess they were trying to say that when orders are added to woocommerce, it is woocommerce that processes the orders, not their theme or plugin.
    Back to my original issue – the maximum inventory works when no customers try to book at same time. So, it is working in general terms. But, if two customers are trying to book at same time, both orders may successfully processed even though there is only one inventory left. I checked the orders’ process time stamps; it was very closed. one order was at 19:27:39, while the next was at 19:28:22. The second order shouldn’t have been processed because there was no enough inventory, but it was successfully processed.
    I enclosed a screenshot of the part of code which the theme developer suggested to look at for you to have a look and see if you can find some solution or make sure it is indeed the theme’s issue. https://fiverr-res.cloudinary.com/image/upload/q_auto,f_auto/v1/secured-attachments/message/attachments/f9bc786cea3dc753467c686e40980f40-1564730644774/maxpeople_20190802082331.png?__cld_token__=exp=1565619700~hmac=ca580b066e94c52eb770d25170fa486c519b991470fad8d64aa0df249d3f96f6
    thanks

    Linda

    (@lindamork)

    Automattic Happiness Engineer

    Hi there,

    Unfortunately I wasn’t able to view the link you included from the theme developer.

    I’m not sure how your theme works with bookings, so it might be differ from default WooCommerce behaviour. Once a customer adds a booking product to the cart, those bookings should not be available to other customers. For example, if a bookable product has a maximum of 8 slots available and someone adds 6 of those slots to the cart, the next customer will find only 2 slots available to be booked.

    To avoid products being removed indefinitely from inventory by an abandoned cart, you can choose a time limit for items left in the cart. If they’re not purchased by the end of this time limit, they’re returned to inventory. You’ll find this setting at WooCommerce > Settings > Products > Inventory.

    It could be that your theme settings are not removing the products from inventory when they’re added to the cart? Or perhaps you are using a custom order status? You might want to test this out by creating a simple product in WooCommerce and see how setting an inventory limit and adding to the cart affects the inventory level. You can learn more about inventory settings here: https://docs.woocommerce.com/document/managing-products/#inventory-tab

    If the default inventory behaviour of WooCommerce isn’t working correctly, then it’s being changed by a plugin or theme. You might want to work through the following to see if this is the case: https://docs.woocommerce.com/document/woocommerce-self-service-guide/#section-4

    Thread Starter neoinwales

    (@neoinwales)

    Hi Linda,
    It works fine when customers make bookings one by one, or not very close. I copied the code from theme (suggested by the theme developer about where to look at). I hope you could give some suggestions. At the moment, they think it is not their theme’s problem.

    if ( ! function_exists( ‘ct_tour_check_availability’ ) ) {
    function ct_tour_check_availability( $post_id, $date=”, $time=”, $adults=1, $kids=0 ) {

    // validation
    if ( empty( $post_id ) || ‘tour’ != get_post_type( $post_id ) ) return esc_html__( ‘Invalide Tour ID.’, ‘citytours’ ); //invalid data
    $max_people = get_post_meta( $post_id, ‘_tour_max_people’, true );
    if ( empty( $max_people ) ) return true; // max people empty means no limit
    $is_repeated = get_post_meta( $post_id, ‘_tour_repeated’, true );

    $post_id = esc_sql( ct_tour_org_id( $post_id ) );
    if ( ! empty( $is_repeated ) && ! ct_strtotime( $date ) ) {
    return esc_html__( ‘Invalid date. Please check your booking date again.’, ‘citytours’ ); //invalid data
    }

    global $wpdb;
    $where = “1=1″;
    $where .= ” AND tour_id=” . $post_id;
    if ( ! empty( $is_repeated ) ) $where .= ” AND tour_date='” . esc_sql( date( ‘Y-m-d’, ct_strtotime( $date ) ) ) . “‘”;
    if ( ! empty( $time ) ) {
    $where .= “AND tour_time='” . esc_sql( $time ) . “‘”;
    }
    $sql = “SELECT SUM(adults) FROM ” . CT_TOUR_BOOKINGS_TABLE . ” WHERE $where”;
    $booked_count = $wpdb->get_var( $sql );
    if ( $booked_count + $adults <= $max_people ) {
    return true;
    } elseif ( $booked_count >= $max_people ) {
    return esc_html__( ‘Sold Out’, ‘citytours’ );
    } else {
    return sprintf( esc_html__( ‘Exceed Persons. Only %d persons available’, ‘citytours’ ), $max_people – $booked_count );
    }
    }
    }

    Many thanks,
    N

    Linda

    (@lindamork)

    Automattic Happiness Engineer

    Hi there,

    That code isn’t part of WooCommerce core and appears to be specific to the bookings plugin you had made. It seems you need to ask the developer you hired to make that plugin to investigate the issue you’re having problems with.

    There’s a WooCommerce Bookings extension if you’re interested which works with WooCommerce compatible themes. If you’re having problems with a custom plugin and can’t get things resolved, you might want to check it out.

    Thread Starter neoinwales

    (@neoinwales)

    Hi Linda,
    I have another reply from the theme developer as below.
    “After customers complete the booking, available slot will be discounted, but customers add tours in cart, available slot will not be discounted.”
    I am not an expert but it looks the way they use isn’t right. can you recommend some solution to change it?
    Thanks

    Linda

    (@lindamork)

    Automattic Happiness Engineer

    Hi again!

    Yes, I’d say you’re quite correct. It sounds like the theme doesn’t work with WooCommerce so that tours added to the cart are reduced from inventory.

    I’d suggest you use a plugin to take your bookings. One issue with combining a feature like bookings with your theme is that if you want to change your theme, you’ll have to somehow migrate your bookings if your new theme doesn’t have that ability – and most don’t.

    There are several booking plugins available for use with WooCommerce which you’ll find by searching ‘WooCommerce booking plugin’. Our WooCommerce Bookings that I mentioned earlier is one suggestion you might wish to look into.

    Thanks for your patience while we worked through this and I hope you find a good, workable solution that meets your requirements. 🙂

    Thread Starter neoinwales

    (@neoinwales)

    thanks Linda.
    WooCommerce Bookings is a plugin, which needs to work with a tour theme. Is it correct? Or it can work alone with wordpress, but will need customization so as to work for tours?
    Thanks

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @neoinwales Bookings is a plugin that requires WooCommerce to work, as it extends the functionality of WooCommerce.

    We have customers that use Bookings for tours, but we cannot guarantee it will suit all needs. Plugins purchased through WooCommerce.com come with a 30 day money back guarantee.

    con

    (@conschneider)

    Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Kind regards,

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘maximum cap not working’ is closed to new replies.