Back to Posts

Using Perch Shop to develop an online booking system

Posted in Learning

As some of you will know I work at a company called Fishtank Creative and the full blog post was posted there.

Perch CMS

Essentially using Perch Shop I had to come up with a way for customers to secure a swimming holiday by paying a 20% deposit and then pay the remaining balance at a later date. To do this we had to create two products

  1. Deposit Product
  2. Remaining Balance Product

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 can read the detailed post on the Fishtank Creative blog but I have posted the code below.

if (perch_get('s')) {

    $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);

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

    if (perch_member_has_tag($tag)) {

        perch_shop_product(perch_get('s'), [
            'template' => 'products/product_v2.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_v2.html',
            'filter'=>array(
                array(
                    'filter'=>'slug',
                    'match'=>'eq',
                    'value'=>perch_get('s')
                ),
                array(
                    'filter'=>'sku',
                    'match'=>'contains',
                    'value' => 'DEP'
                ),
            )
        ]);

    }
}

The code above is simply displaying both products on the same page. We then filter the two products to only show the product with a SKU code that contains DEP.

Next when a customer purchases the deposit product they get assigned a Perch Tag. The tag will be the SKU code of the deposit product.

So now what happens the code will check if they have that tag, if they do I will display the remaining balance product.