We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem, Shop

checkout.php (Nest Demo)

<?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');

confirm.html from nest example (plus my addition)

<div class="box shop minor">
<perch:form id="confirm" app="perch_shop" class="order-confirm">
    <perch:label for="terms">
        <perch:input type="checkbox" value="true" id="terms" cart-property="terms_agreed" required="true" />
        I agree to the terms and conditions.
    </perch:label>
    <perch:input type="text" id="helloworld" cart-property="hello" required="true" />
    <div>
        <perch:input type="submit" value="Pay now" class="button" />
    </div>

    <p><strong>Note:</strong> this demo uses the <i>manual</i> payment gateway (useful for orders by P.O. for example). In most real examples, this next step would take you to a payment gateway pay-page. For the demo you'll go directly to the payment success page.</p>
</perch:form>
</div>

all working... I get hello = value entered in the Additional Information

There is a wealth of info in the Nest demo... :)

PS: Make sure you set the cart property attrabute cart-property="hello"

Duncan Revell

Duncan Revell 78 points
Registered Developer

Aah, nice one Robert - I hadn’t realised that kind of info (cart-property) would get passed through to the order too. Don’t know why I assumed it just finished at the cart...

You learn something new everyday!

Duncan Revell said:

Aah, nice one Robert - I hadn’t realised that kind of info (cart-property) would get passed through to the order too. Don’t know why I assumed it just finished at the cart...

You learn something new everyday!

Honestly, it took a lot of breaking down the “Nest” demo to learn some of this stuff. I know the documentation is very little on some of this and I would love to complain but honestly, I’m not going to cause I know it would take an immense amount of time which could better be used to improve the products. For these reasons, I monitor the forum and break down the apps line by line sometimes in order to understand and help others when I can.

Nik Gill

Nik Gill 1 points

Thanks Robert, I shall have a go at that later today and let you know how I get on. Your efforts are very much appreciated on this, Thanks!!!

Nik Gill said:

Thanks Robert, I shall have a go at that later today and let you know how I get on. Your efforts are very much appreciated on this, Thanks!!!

Sure thing man, any time...

do you think there is a way to programmatically add something here? on checkout I'm sending data to DHL for shipping and they send back a tracking number ... it'd be great if I could add that number into this section directly via php as there wouldn't be a way to do it (your form solution) behind the scenes in an Ajax call.

Robert Ketter said:

So, All you have to do is on your checkout page you need to call perch_shop_form() with a template as option, in this template you can gather any additional fields you want like where to leave package, phone number to call or ... then this information will be passed as key=>value to the "Additional Information" section on the bottom of the Order page in the admin.

So everything you want is already part of Perch_Shop.... you just gotta be patient... lol

Remember, I was part of the very extensive Perch_Shop beta developers so I really am pretty informed about this... lol

RK

Maybe, but I can't seem to get my head around this idea today. It's likely something you would need javascript to handle, maybe populating a hidden field. IDK

RK

Duncan Revell

Duncan Revell 78 points
Registered Developer

Blake,

I believe there is a perch_shop_set_cart_property(property, value) function and a perch_shop_get_cart_property(property)

Nik Gill

Nik Gill 1 points

Hey Robert, Sorry to resurrect this one again... didn't get a chance to implement this earlier so had a go this afternoon.

I'm not getting anything through in the additional information panel when I implement that code... in fact I'm not getting the panel appear at all now, usually it details the status 'paid' in that panel but the whole table is not showing now oddly.

Have put the additional information inputs in the confirm.html template and it's showing ok on page and the buttons all work to take you to the gateway

<?php perch_shop_cart(['template' => 'cart/cart_static.html']);?>
<?php perch_shop_form('checkout/confirm.html');?>

This is how I've put the additional form fields into my template

<perch:form id="confirm" app="perch_shop" class="confirm">

<div>
    <perch:label for="shipping_gift">Contact Tel No.</perch:label>
    <perch:input type="text" id="tel-no" cart-property="tel-no" required="false" class="field" />
    </div>

    <div>
    <perch:label for="shipping_instructions">Delivery Instructions</perch:label>
    <perch:input type="textarea" id="shipping_instructions" cart-property="shipping" required="false" class="field"/>
    </div>

    <div>
    <perch:label for="shipping_gift">Gift Message</perch:label>
    <perch:input type="textarea" id="shipping_gift" cart-property="gift" required="false" class="field"/>
    </div>

<div>
<a href="/checkout/" class="button">Pay with credit card</a>
<a href="/checkout/paypal.php" class="button paypal">Pay with Paypal</a>
</div>
</perch:form>

Can you spot anything I've not done right, or not done at all?

Cheers in advance

Nik