Search

I want to implement the folloving task. That’s a simple emulation of online store:

I have two sections Products:fields[id, name] And Orders: Orders:fields[id, cart(items)]

A have a limited number of UNIQ products, say five (A, B, C, D, E). And my order can consist of any number of UNIQ products (1,2,3,4 or five), whatever the shopper wants.

It goes fine when the shopper wants to order only 1 item of UNIQ produts.

He pushes the button submit and i get his order in backend.

He or she may have up to 5 different products then but what if the Shopper wants to have 3 items of A, 1 item of B and 10 items of C

He pushes the Submit button and… I dont know how to handle quantity of items per product. Where can I keep them? Which section or field should receive them with? How Subcection manager can contain 3 copies of A? How can it be acheived?

That’s the question!

Is the “Cart” field in “Orders” a Subsection Manager? If it is, the entry would have a Select Box Link linking to the product name, and a Text Input field (or Number field) to store the quantity.

It is a Subsection manager linked to products.

Which entry? I still cant get it. A want to have in my order the followin list:

3xA 2xB 4xC

All in a single entry of section Orders.

If it’s a Subsection manager then your order will comprise of multiple entries: one entry in Orders (where you collect the name, address etc) and one entry in the subsection manager for each row in your shopping cart (item + quantity).

So you have three sections:

  • Products: Name, Description, Image etc.
  • Orders: Name, Address, Date, Items (Subsection Manager, linked to Order items)
  • Order Items: Product (Select Box Link to Products), Quantity

k now i have three sections. I’ve made up an event out of Orders.

How can I submit form data into section Orders, so that I got new Order Items entry created? i.e. how to create an entry sending an item into subsection manager event and create both linked product and quantity?

How can I handle subsection manager if Order Items section entry I want to add to doesnt exist at the moment of submitting

Or you suppose to create an entry in Order Items on every add to basket event and then make a form out of those? Which in its turn can be sent to Orders?

It’s a bit tricky task. I’m not sure if my solution is optimal, but it works.

The Section scheme is almost same with one mentioned by Nick, except Order items are linked to Orders with Select Box Link:

  • Products: Name, Description, Image etc.
  • Orders: Name, Address, Date
  • Order Items: Product (Select Box Link to Products), Order (Select Box Link to Orders), Quantity

There are two Events:

  • “A Process Order”
  • “Z Process Order Items”

Events naming is meaningfull, because (as far as I know) Symphony process events in alphabet order. Then I create custom Filter extension, which use EventPostSaveFilter delegate and connect this filter to the first event. The role of this extension is transform first event’s data so that second one can accept and process it. The code looks like this (pseudo code):

public function processEventData($context){

    $order_id = $context['entry']->get('id');

    $items = $context['fields']['items'];
    $quantity = $context['fields']['quantity'];

    $_POST = null;

    foreach($items as $k => $v){
        $_POST['fields'][$k]['order'] = $order_id;
        $_POST['fields'][$k]['product'] = $items[$k];
        $_POST['fields'][$k]['quantity'] = $quantity[$k];
    }

    $_POST['action']['z-process-order-items'] = true;

}

That my work have been done about a year ago. And I didn’t remember all details already. But briefly – that’s the idea.

hey, andrrr i guess you do speak russian Can you please get in touch with me via mail ibcico[at]gmail.com or whatever as i can’t find any of your contacts

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details