Forum

Thread tagged as: Shop

Error on checkout confirm page

I am getting an error while clicking on Pay Now button on Checkout Confirm page.

Warning: array_merge(): Argument #1 is not an array in /public/perch/addons/apps/perch_shop/lib/PerchShop_Cart.class.php on line 494

Strange thing is that I am getting this error on development server while its working fine on localhost. Please help.

Thanks,

Lindsay Masten

Lindsay Masten 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Shop has no "Pay Now" button and no Checkout Confirm page - those are things you've built. As such, I'll need to know something about what you're doing, what software you're using, which gateway, and so on in order to even begin to try to help.

Lindsay, is it safe to say “your using the Nest example” and built it into your site?

Both of those “Pay Now” and “Checkout Confirm” sounds like that example.

Just courious.... not that this changes anything.

Full disclosure, right now my forum replies are a little weird as I'm sharing my Perch account with a second developer who is helping me with one of two Perch websites I'm working on.

Hi Robert, yes, I believe we are.

Thanks for replying, Drew — right now we're building the checkout based on the Nest example. The site is a Perch site, the gateway is going to hopefully be Square (per our earlier email) but for now it's set to manual.

The site is working (aka going through the checkout process) as desired in a local environment, but when we transfer it to our server we're seeing the error listed above. Here's what the code for the page templates look like:

cart.php

<?php
    perch_layout('global.above', array(
            'title'           => perch_page_title(true),
            'section_heading' => 'shop',
        ));

    PerchSystem::set_var('empty_cart_message', perch_content('Your cart is empty', true));
    perch_shop_cart();

    perch_layout('shop.sidebar', array(
            'promo' => true,
            'shipping' => true,
            'currency' => true,
        ));

    perch_layout('global.below');

checkout.php

<?php

    if (!perch_member_logged_in()) {
        PerchSystem::redirect('/shop/register');
    }

    if (perch_shop_cart_has_property('terms_agreed')) {
        perch_shop_checkout('manual', [
            'return_url' => '/shop/result',
            'cancel_url' => '/shop',
            ]);
    }

    perch_layout('global.above', array(
            'title'           => perch_page_title(true),
            'section_heading' => 'shop',
        ));

    // Show the cart with a non-interactive template
    perch_shop_cart([
        'template'=>'cart/cart_static.html'
    ]);

    // Show the order addresses
    perch_shop_order_addresses();

    // Display the form with the T&Cs checkbox
    perch_shop_form('checkout/confirm.html');

    perch_layout('shop.sidebar', array(
            'promo' => false,
            'shipping' => false,
            'currency' => false,
            'minicart' => false,
            'social' => false,
        ));

    perch_layout('global.below');

result.php (confirmation page)

<?php

    perch_layout('global.above', array(
            'title'           => perch_page_title(true),
            'section_heading' => 'shop',
        ));


    // Has the order been succcessfully placed?
    if (perch_shop_order_successful()) {

        // Yes! Show a success message
        perch_content('Order successful');

        // Redisplay the details of the order
        perch_shop_order_items(
            perch_shop_successful_order_id()
        );

        perch_shop_empty_cart();

    }else{

        // Payment problem! Show instructions to the customer
        perch_content('Payment not successful');
    }


    perch_layout('shop.sidebar', array(
            'promo'     => false,
            'shipping'  => false,
            'currency'  => false,
            'minicart'  => false,
            'social'    => false,
            'password'  => true,
            'downloads' => true,
        ));

    perch_layout('global.below');

Here's a link to the site on the development server: https://198.199.96.18/

Please enable debug on dev so we can see the debug output which may solve this quickly. The posted templates really don’t have enough info to pinpoint the issue. At least not for me.

Add

define(PERCH_DEBUG, true);

To config.php

At least not for me.

Same! Thanks Robert.

Add

define(PERCH_DEBUG, true);

To config.php

Done.

I am sorry Lindsay, I am not seeing the debug output... you did enable on the https://198.199.96.18/perch/config/config.php

Normally you wouldn't do on public dev, but none of the output is sensitive info, just a bunch of debug comments.

BTW - Beautiful Site.

Hi Robert,

Sorry for the delay in my response. I did enable the debug output at that location (see: https://recordit.co/wm7tHqPAxR).

Could there be something preventing the debug from working?

Drew McLellan

Drew McLellan 2638 points
Perch Support

If this is Perch and not Runway, you'll need to output the debug too.

https://docs.grabaperch.com/perch/building/troubleshooting/how-do-i-debug-problems/

Drew McLellan said:

If this is Perch and not Runway, you'll need to output the debug too.

https://docs.grabaperch.com/perch/building/troubleshooting/how-do-i-debug-problems/

Wow, I can’t believe I forgot that part, it’s been so long since I used Perch, I as so used to Runway only. Thanks.

Ah, thank you both! I have added output for the debug globally. It's at the end of the global header, so just scroll down to use the site as needed.

Thanks again.

Invalid query: SQLSTATE[HY000]: General error: 1364 Field 'countryID' doesn't have a default value Customer or Address or Shipping missing

debug output

Checking out with manual
Member ID: 38
[1] SELECT * FROM perch2_shop_customers WHERE memberID=38
[1] SELECT billingAddress, shippingAddress FROM perch2_shop_cart WHERE billingAddress IS NOT NULL AND cartID=65
[1] SELECT * FROM perch2_shop_addresses WHERE customerID='32' AND orderID IS NULL AND countryID>0 AND addressSlug='default'
no address
[1] SELECT * FROM perch2_shop_addresses WHERE customerID='32' AND orderID IS NULL AND countryID>0 AND addressSlug='default'
INSERT INTO perch2_shop_addresses(addressDynamicFields,addressTitle,addressSlug,addressCreated) VALUES('{\"first_name\":\"Robert\",\"last_name\":\"Ketter\",\"address_1\":false,\"address_2\":false,\"postcode\":false,\"country\":false,\"company\":false,\"city\":false,\"customer\":\"32\",\"phone\":false,\"county\":false,\"instructions\":false}','default','default','2017-10-12 09:57:46')
Invalid query: SQLSTATE[HY000]: General error: 1364 Field 'countryID' doesn't have a default value
[1] SELECT * FROM perch2_shop_addresses WHERE customerID='32' AND orderID IS NULL AND countryID>0 AND addressSlug='shipping'
no address
[1] SELECT * FROM perch2_shop_addresses WHERE customerID='32' AND orderID IS NULL AND countryID>0 AND addressSlug='default'
INSERT INTO perch2_shop_addresses(addressDynamicFields,addressTitle,addressSlug,addressCreated) VALUES('{\"first_name\":\"Robert\",\"last_name\":\"Ketter\",\"address_1\":false,\"address_2\":false,\"postcode\":false,\"country\":false,\"company\":false,\"city\":false,\"customer\":\"32\",\"phone\":false,\"county\":false,\"instructions\":false}','shipping','shipping','2017-10-12 09:57:46')
Invalid query: SQLSTATE[HY000]: General error: 1364 Field 'countryID' doesn't have a default value
Customer or Address or Shipping missing

This is the error, so I am wondering if your form contains the Country Code field?

It does:

<div class="form-group"> <label for="country" class=" control-label">COUNTRY*</label> <perch:input type="text" id="country" label="Country" placeholder="Enter your country..." class="form-control" /> </div>

It seems like the error message "countryID' doesn't have a default value Customer or Address or Shipping missing" indicates that we need to add a default from within the CMS or somewhere in a config file... does that sound right?

<perch:label for="country">Country</perch:label> <perch:input type="select" options="<perch:shop id="country_list" />" value="236" id="country" label="Country />

You see the special options attribute...

Hi Robert,

<perch:label for="country">Country</perch:label>
<perch:input type="select" options="<perch:shop id="country_list" />" value="236" id="country" label="Country />

I have already tried this tag to populate countries in drop-down but in my case its not working.