Forum

Thread tagged as: Problem, MailChimp, Shop

Mailchimp signup from Checkout form not working

Hi,

I am using the customer_create_passwordless form from Shop to also sign people up to a mailing list if they check a box to ask to do so. This is my template code:

<div class="checkout">
<div class="checkout-section" id="details">
    <perch:form id="register" method="post" app="perch_mailchimp perch_shop" action="/shop/checkout" type="default">

        <h2>1. Your Details</h2>

        <div class="infieldlabel">
            <perch:input type="email" mailer="email" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="email" required="true" value="<perch:if exists="customerEmail"><perch:shop id="customerEmail"/></perch:if>" />
            <perch:label for="email" class="infield required">Your Email for Order Confirmation</perch:label>
            <perch:input type="hidden" id="password" value="__auto__" />
        </div>

        <div class="row">

            <div class="infieldlabel half">
                <perch:input type="text" mailer="FNAME" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="first_name" required="true" label="First name" value="<perch:if exists="addressFirstName_0"><perch:shop id="addressFirstName_0"/></perch:if>" />
                <perch:label for="first_name" class="infield required">First name</perch:label>
            </div>

            <div class="infieldlabel half">
                <perch:input type="text" mailer="LNAME" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="last_name" required="true" label="Last name" value="<perch:if exists="addressLastName_0"><perch:shop id="addressLastName_0"/></perch:if>" />
                <perch:label for="last_name" class="infield required">Last name</perch:label>
            </div>

        </div>

        <div class="infieldlabel">
            <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="phone" cart-property="phone_number" value="<perch:if exists="phone_0"><perch:shop id="phone_0"/></perch:if>"/>
            <perch:label for="phone" class="infield">Phone Number</perch:label>
        </div>

        <div class="checkboxwrapper">
          <perch:input type="checkbox" value="1" id="mailinglist_checkbox" mailer="confirm_subscribe" />
          <perch:label for="mailinglist_checkbox">Add me to the Newgate Watches mailing list</perch:label>
        </div>


        <h3>Billing address</h3>

        <div class="infieldlabel">
            <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="address_1" required="true" label="Address 1" value="<perch:if exists="address_1_0"><perch:shop id="address_1_0"/></perch:if>" />
            <perch:label for="address_1" class="infield required">Address 1</perch:label>
        </div>

        <div class="infieldlabel">
            <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="address_2" label="Address 2" value="<perch:if exists="address_2_0"><perch:shop id="address_2_0"/></perch:if>" />
            <perch:label for="address_2" class="infield">Address 2</perch:label>
        </div>

        <div class="row">

            <div class="infieldlabel third">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="city" label="City" required="true" value="<perch:if exists="city_0"><perch:shop id="city_0"/></perch:if>" />
                <perch:label for="city" class="infield required">Town / City</perch:label>
            </div>

            <div class="infieldlabel third">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="county" label="County" value="<perch:if exists="county_0"><perch:shop id="county_0"/></perch:if>" />
                <perch:label for="county" class="infield">County / State</perch:label>
            </div>


            <div class="infieldlabel third">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="postcode" label="Postal code" required="true" value="<perch:if exists="postcode_0"><perch:shop id="postcode_0"/></perch:if>" />
                <perch:label for="postcode" class="infield required">Postcode / Zip</perch:label>
            </div>

        </div>

        <div>
          <perch:input type="select" options="<perch:shop id="country_list" />" value="<perch:if exists="country_0"><perch:shop id="country_0"/><perch:else />236</perch:if>" id="country" label="Country" required="true" />
        </div>

        <div class="row">
        <h3 class="half">Shipping address</h3>

        <div class="checkboxwrapper half">
          <input type="checkbox" name="checkbox" id="toshipping_checkbox" />
          <label for="toshipping_checkbox">Same as Billing Address</label>
        </div>
        </div>
        <div class="row">
            <div class="infieldlabel half">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_first_name" required="true" label="First name" value="<perch:if exists="addressFirstName_1"><perch:shop id="addressFirstName_1"/></perch:if>" />
                <perch:label for="shipping_first_name" class="infield required">First name</perch:label>
            </div>

            <div class="infieldlabel half">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_last_name" required="true" label="Last name" value="<perch:if exists="addressLastName_1"><perch:shop id="addressLastName_1"/></perch:if>" />
                <perch:label for="shipping_last_name" class="infield required">Last name</perch:label>
            </div>
        </div>

        <div class="infieldlabel">
            <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_address_1" required="true" label="Address 1" value="<perch:if exists="address_1_1"><perch:shop id="address_1_1"/></perch:if>" />
            <perch:label for="shipping_address_1" class="infield required">Address 1</perch:label>
        </div>

        <div class="infieldlabel">
            <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_address_2" label="Address 2" value="<perch:if exists="address_2_1"><perch:shop id="address_2_1"/></perch:if>" />
            <perch:label for="shipping_address_2" class="infield">Address 2</perch:label>
        </div>
        <div class="row">
            <div class="infieldlabel third">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_city" label="City" required="true" value="<perch:if exists="city_1"><perch:shop id="city_1"/></perch:if>" />
                <perch:label for="shipping_city" class="infield required">Town / City</perch:label>
            </div>

            <div class="infieldlabel third">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_county" label="County" value="<perch:if exists="county_1"><perch:shop id="county_1"/></perch:if>" />
                <perch:label for="shipping_county" class="infield">County / State</perch:label>
            </div>

            <div class="infieldlabel third">
                <perch:input type="text" <perch:if exists="addressFirstName_0">class="hascontent"</perch:if> id="shipping_postcode" required="true" label="Postal code" value="<perch:if exists="postcode_1"><perch:shop id="postcode_1"/></perch:if>" />
                <perch:label for="shipping_postcode" class="infield required">Postcode / Zip</perch:label>
            </div>
        </div>

        <div>
          <perch:input type="select" options="<perch:shop id="country_list" />" value="<perch:if exists="country_1"><perch:shop id="country_1"/><perch:else />236</perch:if>" id="shipping_country" label="Country" required="true" />
        </div>

        <div>
          <perch:input type="hidden" id="list" value="02fecf19cd" mailer="list" />
            <perch:input type="submit" value="Continue to Delivery Options" />
        </div>

    </perch:form>
</div>
</div>

When I click submit the shop form works as expected, but the mailchimp subscription is not working. I am getting this in debug:

Array
(
    [type] => 8
    [message] => Undefined variable: email
    [file] => /Volumes/Data/g Websites/newgatewatches/newgate-watches/admin/addons/apps/perch_mailchimp/lib/PerchMailChimp_Subscribers.class.php
    [line] => 68
)

And this from Mailchimp:

Array
(
    [headers] => Array
        (
            [url] => https://us12.api.mailchimp.com/3.0/lists/02fecf19cd/members
            [content_type] => application/problem+json; charset=utf-8
            [http_code] => 400
            [header_size] => 417
            [request_size] => 408
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 0.727723
            [namelookup_time] => 0.432245
            [connect_time] => 0.432602
            [pretransfer_time] => 0.564999
            [size_upload] => 74
            [size_download] => 332
            [speed_download] => 456
            [speed_upload] => 101
            [download_content_length] => 332
            [upload_content_length] => 74
            [starttransfer_time] => 0.727607
            [redirect_time] => 0
            [redirect_url] => 
            [primary_ip] => 104.82.181.71
            [certinfo] => Array
                (
                )

            [primary_port] => 443
            [local_ip] => 192.168.100.43
            [local_port] => 52652
            [request_header] => POST /3.0/lists/02fecf19cd/members HTTP/1.0
Host: us12.api.mailchimp.com
User-Agent: DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)
Accept-Encoding: deflate, gzip
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Authorization: apikey b8e0b18debe717ba1efe75f01703f85b-us12
Content-Length: 74


        )

    [body] => {"type":"https://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. For field-specific details, see the 'errors' array.","instance":"","errors":[{"field":"","message":"Required fields were not provided: email_address"},{"field":"email_address","message":"Schema describes string, NULL found instead"},{"field":"merge_fields.LNAME","message":"Data did not match any of the schemas described in anyOf."}]}
)

I have mailer="email" defined on the input, so I am not sure where I am going wrong. If you could shed any light that would be great. This is my short diagnostics:

SUMMARY INFORMATION

Perch Runway: 2.8.31, PHP: 5.6.25, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_forms (1.8.3), perch_shop_orders (PERCH_SHOP_VERSION), perch_shop_products (1.0.8), perch_shop (1.0.8), perch_members (1.5), perch_mailchimp (3.0.1), perch_twitter (3.6.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_mailchimp', 'perch_twitter', 'perch_members', 'perch_shop', 'perch_blog' );
PERCH_LOGINPATH: /admin
PERCH_PATH: /Volumes/Data/g Websites/newgatewatches/newgate-watches/admin
PERCH_CORE: /Volumes/Data/g Websites/newgatewatches/newgate-watches/admin/core
PERCH_RESFILEPATH: /Volumes/Data/g Websites/newgatewatches/newgate-watches/admin/resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 64M, Memory: 256M, Total max file upload: 64M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: newwatches.dev
DOCUMENT_ROOT: /Volumes/Data/g Websites/newgatewatches/newgate-watches
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php

Thanks!

Mike

Mike Harrison

Mike Harrison 37 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you test without the nested tags?

Just done a test without them and it worked, so it is something to do with them! Will add it back in bit by bit and see where it breaks.

Thanks Drew