Forum

Thread tagged as: Question, Members, PayPal

How do I use a Perch Shop Custom array in a Perch Members function?

Some background for what I'm doing: Client wants to use PayPal shop, yet needs to provide a discount on products to members that are logged in, so I've set-up a category called members that contains a duplicate of every product except with member pricing and a different product code. I want to display all products except those in the members category to non-logged-in visitors, and all products in the members category to logged-in visitors.

The following is what I've got so far, which is attempting to jam the perch_shop_custom function into the one that checks if the visitor is a logged-in member or not. This yields the white screen of death, which tells me it's the wrong approach. I've been rearranging things for hours and have gotten nowhere. How do I format this?

<?php
    if (perch_member_logged_in()) {
        echo'
    '.perch_shop_custom(array(
    'category'=>array('members'),
    'template'=>'shop/product_in_list.html',
    'sort'=>'productTitle',
    'sort-order'=>'ASC'
)).'';?>    
<?php}else{
        echo ''.perch_shop_custom(array(
    'category'=>array('all','!members'),
    'template'=>'shop/product_in_list.html',
    'sort'=>'productTitle',
    'sort-order'=>'ASC'
)).'';?>

We're on Perch 2.7.10, and the latest Members app version.

Gary Iverson

Gary Iverson 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Your if statement looks incorrectly formatted.

If you are going to write any PHP then you need to have access to your error log, the "white screen of death" shows you have a PHP error. You need to be able to see the actual errors by either outputting them to the screen or by being able to look at the log itself.

So that would be your first step, to make sure you can see any errors generated by your code.