Forum

Thread tagged as: Problem, Shop

Checkout error

Hi! This is related to this other ticket but I open a new one since I marked the other as solved.

The problem I am trying to fix is this error on checkout.

Uncaught Error: Call to a member function customerFirstName() on boolean in
.../addons/apps/perch_shop/lib/gateways/PerchShopGateway_default.class.php:239

In my local copy I did truncate these tables (orders, addresses and customers) and the above issue was gone. However I noticed some strange stuff after that and prefer not to do the same in production. So I'm still stuck with the customerFirstName() error.

I have everything up to date by the way. Please let me know if there is any code from my project that would help solve that. my checkout.php is as follows:

<?php
    if (perch_member_logged_in() && perch_post('payment_method_nonce')) {
        $return_url = '/paymentsuccess';

        perch_shop_checkout('braintree', [
            'return_url' => $return_url,
            'token'      => perch_post('payment_method_nonce')
        ]);
    }

    perch_layout('global/header', [
        'body-class' => 'checkout',
        'title' => perch_pages_title(true),
        'slider' => false,
    ]);
?>
<section class="checkout__main">
    <?php
    if (perch_member_logged_in()) {
        perch_shop_payment_form('braintree');
    }
    ?>
</section>
Proko Mountrichas

Proko Mountrichas 3 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

So do you think you have a problem in your data?

Do you mean the customer's data? If I echo them before I submit the checkout they appear correctly.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I didn't mean the customer's data - I meant the data as a whole for your site.

So if the data is ok, why the error? And why is it fixed by deleting the data?

I can only assume that there is a problem with the data as a whole then. Do you think I can try anything else before I empty the tables in prod?

OK I emptied the above mentioned tables in prod too and now checkout works but I see the same strange thing I'm seeing in local. Please let me know if I can have some help on that or I have permanently voided my warranty :)

The problem is that whatever the customer buys I always have in the order the actual product they buy plus another product (always the same). This only affects the perch side. I mean the transaction completes correctly and in my gateways dashboard I can see the correct info and amount charged. However in perch when I use perch_shop_order() to get it's info I see this extra line item. It also appears in the order in perch admin.

This extra product is not in the cart but can't get rid of it.

Would be awesome if you could suggest some troubleshooting.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Where does the other product come from?

I have no clue. It's just a regular product. The store only has 3 products A, B and C. If customer buys A, I get 2xA in the order info. If they buy B, I get A+B and if C I get A+C. So A is always there. I suppose it pulls it from the database.

Drew McLellan

Drew McLellan 2638 points
Perch Support

How are you adding items to the cart?

I found were it was coming from. After truncating the orders table it started to count from 0 and took the extra item from the perch2_shop_order_items table which was still holding test data. It just happened that all the test transactions had been done with the same product. What would maybe be useful is make a note of the original Uncaught Error. I couldn't wait for a proper solution for this one since we were loosing money but this happened without me having touched the database at all. It is the 2nd time it appears to the forum. Unfortunately there are loads of merges to the codebase since I first added and successfully tested payments in production and the appearance of the error.