Using Perch Shop to develop an online booking system

After our first meeting with our clients at Big Blue Swim, what stood out the most was their need for customers to be able to pay for their swimming holiday online. Previously all bookings were taken via email or telephone. This became unsustainable with the amount of bookings that were incoming.

Our task was to develop a booking system that allowed customers to secure a place on a swimming holiday without paying the full amount at once.

The client wanted the customer to first pay 20% to secure their place, then pay the remaining balance nearer the time of the holiday.

Due to budget restrictions we couldn’t build a completely bespoke system so we needed to come up with a solution to fit the brief but also stay within budget. The original website was built using Perch (Perch 1) so we thought lets use Perch Runway and Perch Shop to build this booking system.

How we did this using Perch Shop

For each swimming holiday we created it as two individual products:

  • Deposit Product
  • Remaining Balance Product

Then assign a tag when the deposit is purchased, and use that to make the balance product available. To do this we created both products with exactly the same title so the slug output was exactly the same. Essentially both products are being viewed on the same page.

We then had to filter those two products based on whether they had a tag or not. The tag needed to be unique so we wanted to use the SKU code but change it slightly.

You will notice at the end of each SKU code it ether has DEP or BAL one being the deposit product and the other being the balance product.

In the Product master page we wanted to put this SKU code into a variable and filter that variable so it only shows the SKU’s with a value of DEP

$sku = perch_shop_products([
    'template' =>'products/product_sku.html',
    'filter'=>array(
        array(
            'filter'=>'slug',
            'match'=>'eq',
            'value'=>perch_get('s')
        ),
        array(
            'filter'=>'sku',
            'match'=>'contains',
            'value' => 'DEP'
        ),
    )
], true);

We then add the SKU tag to the deposit product in the Perch CMS.

The Solution

So we wanted the deposit product to be shown first on the website, then when a customer purchases a deposit product they get assigned a DEP tag and then if a customer has that tag they get shown the remaining balance product.

// Strips out all whitespace
$tag = preg_replace('/\s+/', '', $sku);

if (perch_member_has_tag($tag)) {

    perch_shop_product(perch_get('s'), [
        'template' => 'products/product.html',
        'filter'=>array(
            array(
                'filter'=>'slug',
                'match'=>'eq',
                'value'=>perch_get('s')
            ),
            array(
                'filter'=>'sku',
                'match'=>'contains',
                'value' => 'BAL'
            ),
        )
    ]);

} else {

    perch_shop_product(perch_get('s'), [
        'template' => 'products/product.html',
        'filter'=>array(
            array(
                'filter'=>'slug',
                'match'=>'eq',
                'value'=>perch_get('s')
            ),
            array(
                'filter'=>'sku',
                'match'=>'contains',
                'value' => 'DEP'
            ),
        )
    ]);

}

I hope you found this useful and it just shows the power of the Perch CMS. I am open to making this better so if anyone has any suggestions please do contact me.


There are no comments.

Leave a Reply