Jump to content

This topic is 8083 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi everyone,

I've been tearing my hair out for a few hours now, so I'm hoping someone out there can save me some time.

I am part way through building an online shopfront, and have everything working product wise, but not order wise. So far all the sites I have seen start off by creating an order via an initial entry button. I do not want to do this because it adds an extra front page to the site and because it leaves a lot of dead orders behind when people don't actually place the order. Since most online shopping is browsing, I only want an order record created if someone actually chooses to buy.

And thats where I'm stuck. I can't work out how to have the "Buy Now" button create an order if there is not one already, and then create the child record for the line item in that order, and then set a token (trying to avoid cookies) to carry the order from then on.

Is this possible, or am I forced to create that order record on initial site entry? The checking part is easy enough (if token = 0) but the rest has me stumped.

Many Thanks,

Sean.

Posted

You should be able to do what you require.

The "Buy Now" button can use the "-new" tag. The order items can be passed over as tokens, or a token with a string of order IDs.

Alternatively, you can use an <iframe>, or dhtml layers, and Javascript variables to hold the order items.

All the best.

Garry

Posted

Hi Garry,

If the order already exists I can easily use a "-new" tag to create a line item to that order by using the order number as a token. Thats pretty standard and no problem for me.

Where I fall down is creating the initial order using the same button, if its the first item to add in. I can check to see if the order exists easily, but I can't work out what code to use if it doesnt exist.

Would you be able to be more specific for me?

I'm also trying to keep this very very simple for browser support reasons, so I'm keeping right away from iframe, dhtml, javascript etc. I also know bugger all about them, so it would just be adding a level of complexity at this point. After I have the basic site running nicely I'll look at further learning.

Thanks for your help,

Sean.

Posted

So you wish to create an order when the first item is added.

Maybe, if "Token.0" = "" then create new order and add item to "Portal.0" ("Portal.0" creates a new portal entry). Then assign the order_id to "Token.0". All other order items can be added using "Portal.0".

You may have to use some Javascript to determin if "Token.0" = "". Or, you can use the [FMP-If] tags to choose how the form is structured.

Hope this helps.

Garry

Posted

Thanks Garry, you have at least put me on the right track for the create part of my problem.

I dont need to specify a portal, just the related field in the form of relatename::field, so that part is cyrstal.

Having gotten that far, I'm now unsure how to:

A) stay on the product page (its a different database and I'd rather not have it drop the user on a "click here to continue")

: put the order number in a token at the same time as creating those records

Thanks again,

Sean.

Posted

You could use frames to hold the order in one and the line items in another. However, I think the use InlineActions and/or Portals to keep the selected items (line items) updated would be best.

A) You could use different frames to hold the order and the product listings.

: You could use something like this:

[FMP-If: token.0 .eq.]

<input type="submit" name="-new" value="Create Order">

[FMP-Else]

<input type="hidden" name="-token.0" value="[FMP-CurrentToken:0]">

<input type="hidden" name="-recid" value="[FMP-CurrentrecID]">

<input type="submit" name="-edit" value="Add to Order">

[/FMP-If]

Then assign the order number in the next format page after the order is created.

Hope this helps.

Garry

Posted

Using inline actions to do the line items would work fine, but I still can't see any way to assign that order number to a token elegantly.

A) I don't think using frames will work. The products frame would not know about the token, so continuing to use that frame will not keep the order. And some browsers dont like frames.

: Thats more or less what I am doing. I don't have a problem creating the record or the line items now.

"Then assign the order number in the next format page after the order is created."

The only way I can see to do this is to have the order database displayed in a window with a button to go back to the products (or checkout or whatever) at least for the first item. Thats fine, will work, and is what everyone else seems to do with filemaker, but is there a better way? Non-Filemaker based sites don't seem to have this clunky feature.

Cheers,

Sean.

Posted

There should be little difference between FM and non-FM methods. If I was doing this in PHP/mySQL I will would still have to select the last record created and assign the order_id to either a session variable or to a "hidden" form field for persistence.

The format file which is called when the order is created contains:

<input type="hidden" name="-token.0" value="[FMP-Field:order_id]">

If you are reusing the same file you can still have this line. It should be empty if no value exists.

All the best.

Garry

Posted

Yes, I would think the methods should be very similar.

I understand that a token of some sort has to be passed regardless of the system.

Maybe I need to break the question down again.

I have 3 databases: Products, Orders, Orderlines.

I start with a format file that accesses Products.

From there I press a "Buy Now" button to create or add to an order. Adding to an order can be done using inline actions in the same (products) format file to create a new record in Orderlines, but if there is no existing order I HAVE to use a different format file to create the order.

I then have to press another button which checks if I am in Orders, create the token, and go back to the orignal format file and the Products database.

This last button press is bad from a users point of view, but I don't see how I can avoid it just using cdml.

Am I wrong? Can anyone give me a specific example?

Thanks,

Sean.

Posted

I believe you could do it all with one page. However, in the meantime, the intermediary page can use an "onload=" parameter of the <body.. tag. The "onload" will call the original page with the token set, it can contain some text, e.g. "creating order....". The user will not have to press any buttons.

All the best.

Garry

Posted

Hmmm. Well, all on one page would be ideal. If you can see a way, I'd appreciate it. I really can't see how it can be done after a few weeks of trying.

If I set a token using inline actions, is it still set when the inline action finishes, or is that the end of its life?

Onload: Thats java right? I wanted to avoid java but maybe that would be ok. I can't quite see how you envisage it being used, but thats because I dont know java. Could you show me an example? Are you using it to like a metatag refresh? I guess they would work...

Another question (I hope you don't mind) with tokens, if a user used the back button on the browser, the tokens may get lost, true? If so, maybe I really don't have any choice but to use cookies instead. If they worked properly I don't think I'd have any more problems, but from what I've read on the forum they are pretty dodgy.

sigh....

Thanks for your help Garry.

Sean.

Posted

Tokens set by InlineActions remain set.

Onload: Thats java right?

No, this is HTML (However, Javascript statements are used to perform DOM actions.)!

<body onload="document.location='http://addr/FMPro?-db...etc'>Creating Order....

This is similar to a META Refresh; either can be used.

Using the back button will restore the page back to its previous display. Which may not reflect the true state-of-affairs.

All the best.

Garry

This topic is 8083 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.