LemonStand Forum: Request information on Cart Page - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Request information on Cart Page

#1 User is offline   Jez-Timms 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 147
  • Joined: 01-November 09

Posted 02 September 2010 - 04:18 AM

Hi,

I would like to extend the cart and need some guidance/help.

I need to ask the consumer from a drop down choice for some delivery times and also a textarea for additional notes.

How do you construct this so that it saves this info through the checkout process and is also displayed in the actual order in the LS backend for the admin to view. This info would also need to be on the customer invoice.

Any ideas?
0

#2 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 3,633
  • Joined: 31-October 09

Posted 02 September 2010 - 05:45 PM

Hi, Jez,

Please read this article: http://lemonstandapp...xisting_models/

Basically, you need to create a simple module which would add new columns to the shop_orders table and extend the order model with corresponding fields. Also you will need to add corresponding controls to any checkout step.

I attached a module example which extends the order model with the customer subscription checkbox. You should use the similar approach, but add 2 fields instead of 1. Your database update script (1.sql) could look like follows:

alter table shop_orders add column x_delivery_time varchar(255);
alter table shop_orders add column x_extra_notes text;


You can start with extracting the archive to the /modules directory in your LS installation and modifying the 1.sql file and the customersubscribe_module.php file:


public function extend_order_model($order)
{
    $order->define_column('x_delivery_time', 'Delivery time')->invisible();
    $order->define_column('x_extra_notes', 'Extra notes')->invisible();
}

public function extend_order_form($order, $context)
{
    if ($context == 'preview')
    {
        $order->add_form_field('x_delivery_time')->tab('Order');
        $order->add_form_field('x_extra_notes')->tab('Order');
    }
}



When you finish you will need to re-login to the Administration Area and make sure that you can see the new controls on the Order Preview page.

In the invoices, you can access the new field through the $order variable:

Delivery time: <?= h($order->x_delivery_time) ?>


You will need to create your own invoice template, of course (http://lemonstandapp..._packing_slips/).

Thanks

#3 User is offline   Jez-Timms 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 147
  • Joined: 01-November 09

Posted 06 September 2010 - 03:13 AM

Hi A,

Followed the instructions and all went well - no errors.

However, nothing is appearing in the order preview OR order itself.

In shop:checkout_shipping_info: I have placed a drop down and notes field for delivery times and delivery notes - these are not appearing at all in the admin:

<li><label for="delivery_time">Delivery Time (Mon-Fri from 9-5pm Only)</label>
    <select name="delivery_time">
      <option value="9-12">9am-12pm</option>
      <option value="12-2">12pm-2pm</option>
      <option value="2-5">2pm-5pm</option>
    </select>
  </li>
   <li><textarea name="extra_notes">Enter any information like: Beware of the Dog or hard to find property.</textarea></li>



Code for the module:

<?php

    class CustomerSubscribe_Module extends Core_ModuleBase
    {
        /**
         * Creates the module information object
         * @return Core_ModuleInfo
         */
        protected function createModuleInfo()
        {
            return new Core_ModuleInfo(
                "Customer delivery",
                "Handles the Delivery Times and Notes requirement",
                "Torpedo Juice" );
        }
        
        public function subscribeEvents()
        {
            Backend::$events->addEvent('shop:onExtendOrderModel', $this, 'extend_order_model');
            Backend::$events->addEvent('shop:onExtendOrderForm', $this, 'extend_order_form');
        }
        public function extend_order_model($order)
        {
            $order->define_column('x_delivery_time', 'Delivery time')->invisible();
            $order->define_column('x_extra_notes', 'Extra notes')->invisible();
        }

        public function extend_order_form($order, $context)
        {
            if ($context == 'preview')
            {
                $order->add_form_field('x_delivery_time')->tab('Order');
                $order->add_form_field('x_extra_notes')->tab('Order');
            }
        }
?>


And SQL:

alter table shop_orders add column x_delivery_time varchar(255);
alter table shop_orders add column x_extra_notes text;


Any ideas?
0

#4 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 3,633
  • Joined: 31-October 09

Posted 06 September 2010 - 02:48 PM

Hi, Jez!

I checked your module (by FTP) and I found that you renamed the module directory to "delivery". You also need to rename the module classes to follow the naming conventions (http://lemonstandapp...nstand_modules/). The module information class should be named Delivery_Module and its file name should be named delivery_module.php. I made these updates in the module for you and now Order Preview page displays the added fields.

Thanks

#5 User is offline   Jez-Timms 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 147
  • Joined: 01-November 09

Posted 06 September 2010 - 03:10 PM

Hi A,

Thank you very much - all working brilliantly. Now with this delivery function you pretty much have Amazon!

LS rocks :) :)
0

#6 User is offline   Eric 

  • Developer
  • PipPipPip
  • Group: Members
  • Posts: 1,290
  • Joined: 04-August 10
  • LocationVancouver, Canada

Posted 06 July 2011 - 03:11 PM

Hi Jez!

Just a friendly reminder that our new Marketplace is up and running. We'd love to see your module up there. If you need help, please let us know.

Thank you
0

Share this topic:


Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users