Date expiring buy button

Would this be hard to do?..

One of my clients sells training courses…which are, natural;ly enough, advertised in advance of the date of the course.

We thought it would be nice if, on the day of the course, the ‘add to cart’ button changed automatically to another button such as ‘expired’ or ‘closed’ or whatever. The shop link would also become inactive.

Strikes me that this is a ‘conditional’ situation, but beyond that (and certainly with PHP coding) I have no idea!

Would it be hard to do?

Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Not hard at all. Make two different HTML layers containing your
buttons, one with and one without the add to cart link. Draw these off
the page (I like above the page for these) on the same page where they
will appear.

Apply the TemplateHelper Action to each of them, set it to create a
“partial” and choose either HTML or PHP for the language (doesn’t
matter for what you are doing). Check the Remove Positioning control.
Give them predictable names, like ‘course_name_buy’ and ‘course_name’.

Draw a Markup Item where you want the button to appear, and paste the
following into it. (If you’re looking at this in Mail, ignore the row
of tildes above and below the block of code.)

<?php
$now = date('Ymd'); // makes 20091113 today
if($now > 20091212){ // the 12th of December, when the course is held
	include('_course_name_buy.html');
}else{
	include('_course_name.html');
}
?>

Adjust the above code to match what you entered for the names of each
button (and the course date), and realize that TemplateHelper will add
an underscore to the beginning of the filename. So if you entered
‘button_1’ and selected PHP as the language, you would get a file
named ‘_button_1.php’ in the same folder as the page that held the
Action.

Walter

On Nov 13, 2009, at 3:50 PM, hugh wrote:

Would this be hard to do?..

One of my clients sells training courses…which are, natural;ly
enough, advertised in advance of the date of the course.

We thought it would be nice if, on the day of the course, the ‘add
to cart’ button changed automatically to another button such as
‘expired’ or ‘closed’ or whatever. The shop link would also become
inactive.

Strikes me that this is a ‘conditional’ situation, but beyond that
(and certainly with PHP coding) I have no idea!

Would it be hard to do?

Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

wow Walter, that was quick…sounds promising, too!

several things:

  1. will the action work in Freeway 2?

  2. I’m confused between the layers and the buttons. You mention making an off-page layer, which I assume will be a carbon copy (almost) of the original table (it is a table fyi). That’s ok and so is applying the template action etc. But then you say “draw a markup item where you want the button to be”…but we haven’t actually mentioned any graphic buttons yet?..and surely graphic images are different than html layers? As it happens I want the button (and hence your PHP code?) to appear in table cells. But where is the actual graphic button?

  3. Why does the PHP code say get the page.html rather than get the image.jpg?

But I’ll give it a whirl as you suggest (although frankly I’d rather do it without an action).

regards
Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I meant Freeway 3…THREE!!! (sorry, 2 was a long time ago! Although I still have the manual for 1…!!!)

H.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I haven’t tested the TemplateHelper in FW3, but I think it might work
there (if by 3 you mean 3.5.latest). If you don’t want to use the
Action, then publish your site, view source, and copy the code that
makes the button and the purchase link. Then replace my code with
something like this:

<?php
$now = date('Ymd'); // makes 20091113 today
if($now > 20091212){ // the 12th of December, when the course is held
	print 'your code here';
}else{
	print 'your code here without the link';
}
?>

Put the button image on the pasteboard, above the page, so it
publishes the image to the Resources folder.

Walter

On Nov 13, 2009, at 4:35 PM, hugh wrote:

wow Walter, that was quick…sounds promising, too!

several things:

  1. will the action work in Freeway 2?

  2. I’m confused between the layers and the buttons. You mention
    making an off-page layer, which I assume will be a carbon copy
    (almost) of the original table (it is a table fyi). That’s ok and so
    is applying the template action etc. But then you say “draw a markup
    item where you want the button to be”…but we haven’t actually
    mentioned any graphic buttons yet?..and surely graphic images are
    different than html layers? As it happens I want the button (and
    hence your PHP code?) to appear in table cells. But where is the
    actual graphic button?

  3. Why does the PHP code say get the page.html rather than get the
    image.jpg?

But I’ll give it a whirl as you suggest (although frankly I’d rather
do it without an action).

regards
Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Forgot to say one thing, you paste all that in a Markup Item that’s iinline within the table cell. If your code has a

tag in it, then strip that off, because a Markup Item always gets wrapped in a p of it’s own.

Walter


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

thanks Walt…yes I’m very familiar with markup and inline table cells…!!!


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter,

Just trying this out and the page is getting an error…

Parse error: syntax error, unexpected T_STRING in /Volumes/Formac_120Gb_Webserver/BISHBASH.COM/test/shopcopy.php on line 354

Line 354 is:

$now = date(‘Ymd’); // makes 20091113 today

The whole of your php chunk as I’ve added into a markup item comes out as:

<?php $now = date('Ymd'); // makes 20091113 today if($now > 20091115){ // the 12th of December, when the course is held print ' '; }else{ print 'image src="Resources/finished.gif" alt="Finished"'; } Hugh _______________________________________________ dynamo mailing list email@hidden Update your subscriptions at: http://freewaytalk.net/person/options

I don’t see an error on line 354. Make sure that you are using
straight “typewriter” single-quotes to surround the date format
string, and if it still complains, try adding the second argument
(optional time) like this:

date('Ymd',time());

But the fact that it’s throwing an error on line 354 leads me to
suspect that you have a line-ending problem, because I do see a frank
error on line 356, and if the PHP interpreter is telling you that it’s
on line 354, then your code is being interpreted as one long line.

Look in the Document Setup / Output tab and make sure your document is
outputting the code in Unix Linefeed format, not (Classic) Mac format.

Then, fix this:

print ’

You have enclosed single-quotes inside of single-quotes. Further on
down the same section of your code, you use double-quotes, which is
fine. If you enclose a string variable in single-quotes, then any
quotes you use inside that variable must either be double-quotes or
“escaped” single-quotes. Otherwise, you end the variable prematurely
and end up with this error.

$foo = 'Jimmy's bicycle is red.'; //good
$foo = 'Jimmy's bicycle is red'; //bad
$foo = "Jimmy's bicycle is red"; //good
$bar = ""Just drive, she said!" -- Stan Ridgeway"; //good
$bar = '"Just drive, she said!" -- Stan Ridgeway'; //good
$bar = ""Just drive, she said!" -- Stan Ridgeway"; //bad

Walter

On Nov 14, 2009, at 7:15 AM, hugh wrote:

Hi Walter,

Just trying this out and the page is getting an error…

Parse error: syntax error, unexpected T_STRING in /Volumes/
Formac_120Gb_Webserver/BISHBASH.COM/test/shopcopy.php on line 354

Line 354 is:

$now = date(‘Ymd’); // makes 20091113 today

The whole of your php chunk as I’ve added into a markup item comes
out as:

<?php $now = date('Ymd'); // makes 20091113 today if($now > 20091115){ // the 12th of December, when the course is held print ' '; }else{ print 'image src="Resources/finished.gif" alt="Finished"'; } Hugh _______________________________________________ dynamo mailing list email@hidden Update your subscriptions at: http://freewaytalk.net/person/options

dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Right, I’ll have a look at this. I note the FW 3.5 preferences give you choice of Mac, Unix or DOS - mine was set on Mac.

As for the quotes thing…yes I see what you mean, it’s just that I believed 9although haven’t proven’ that the single quotes were a required piece of the form code needing to be read by the shopping cart processor. I’ll try with double quotes or even without and see what happens.

I’ll get back.

Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

print ‘ painting machinery & industrial equipment, July 16th, Buxton’>

Oh, and where’s your opening tag? I only see the closing there in the code you quoted.

Walter


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If it turns out that you must have single-quotes, then simply escape
them. You don’t have to choose one over another. You currently have a
mix of quote styles in a single run of HTML, which won’t confuse a
browser but will definitely make your coding harder.

Walter

On Nov 14, 2009, at 9:54 AM, hugh wrote:

As for the quotes thing…yes I see what you mean, it’s just that I
believed 9although haven’t proven’ that the single quotes were a
required piece of the form code needing to be read by the shopping
cart processor.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’ve changed my output line endings to Unix, trust that’s ok.

Also added the start of the form action!!..thanks.

Inserted markup is now this:

<?php $now = date('Ymd'); // makes 20091113 today if($now > 20091115){ // the 16th of Nov, when the course is held print ' '; }else{ print 'image src="Resources/finished.gif" alt="Finished"'; } ?>

Not getting any error messages now, but just seeing the text of the markup item rather than any button in the tablecell. And yes the web space is PHP enabled (v4.4.2)

??

http://www.conformance.co.uk/shopcopy.php

(ignore all the missing images etc, just see first five rows of the shop table…the addtocart.gif and the finished.gif have both been uploaded and should be available.)


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You might want to try quoting all your attributes.

<?php
$now = date('Ymd'); // makes 20091113 today
if($now > 20091115){ // the 16th of Nov, when the course is held
	print '<form action="http://www.romancart.com/cart.asp" method="post">
	<input type="hidden" name="itemname" value="Introduction to painting  
electrical equipment, Aug 21, Dorking">
		<input type="hidden" name="price" value="275.00">
		<input type="hidden" name="storeid" value="11111">
		<input type="hidden" name="quantity" value="1">
		<input type="image" src="Resources/addtocart.gif" alt="Buy">
		</form>';
}else{
	print '<image src="Resources/finished.gif" alt="Finished" />';
}
?>

Also, your image tag for finished doesn’t have its surrounding < > to
make it a tag – I fixed it above.

Walter

On Nov 14, 2009, at 12:36 PM, hugh wrote:

I’ve changed my output line endings to Unix, trust that’s ok.

Also added the start of the form action!!..thanks.

Inserted markup is now this:

<?php $now = date('Ymd'); // makes 20091113 today if($now > 20091115){ // the 16th of Nov, when the course is held print ' '; }else{ print 'image src="Resources/finished.gif" alt="Finished"'; } ?>

Not getting any error messages now, but just seeing the text of the
markup item rather than any button in the tablecell. And yes the web
space is PHP enabled (v4.4.2)

??

http://www.conformance.co.uk/shopcopy.php

(ignore all the missing images etc, just see first five rows of the
shop table…the addtocart.gif and the finished.gif have both been
uploaded and should be available.)


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

We are edging closer, Walter…!! At same address as before, you will now see the ‘Finished’ buttons rather than just code, so that’s a step forward.

However, it is just displaying ‘Finished’ for everything. I have set the first two items to close on 16th Nov, and the others to close on 17th, 18th and 19th respectively - so the bottom three items should be showing ‘Add to Cart’ buttons and be active links.

Code for item 4, for example, is:

<?php $now = date('Ymd'); // makes 20091113 today if($now > 20091118){ // the 16th of Nov, when the course is held print ' '; }else{ print ''; } ?>

Thanks for noticing the <>tag missing for image. I removed the space and forward slash near the end of your code…I couldn’t see what it did?.. It didn’t work with the slash in, either.

Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Do you have the “show errors” code in this same page, before these
lines occur? Try adding them if not; use the Before HTML slot of the
Page / HTML Markup dialog and add the following:

<?php
	ini_set('display_errors',1);
	error_reporting(E_ALL);
?>

Also, just as a debugging step, try printing out your $now. Add a line
after the one that begins with $now that reads:

print $now;

and see what exactly is being made here for your comparison. If the
date comes out correctly, then great. But if it isn’t working (say, if
you get December 31, 1969 in ISO format) then you will need to add the
second argument ( time() ) to the Date function, as I noted earlier. I
would be surprised if that was it, but you never know.

Walter

On Nov 15, 2009, at 9:31 PM, hugh wrote:

We are edging closer, Walter…!! At same address as before, you
will now see the ‘Finished’ buttons rather than just code, so that’s
a step forward.

However, it is just displaying ‘Finished’ for everything. I have set
the first two items to close on 16th Nov, and the others to close on
17th, 18th and 19th respectively - so the bottom three items should
be showing ‘Add to Cart’ buttons and be active links.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter, sorry been away for a couple of days.

OK, I added the php error code to before html, and also put the ‘print’ line in you suggested.

http://www.conformance.co.uk/shopcopy.php

Can’t see any error codes being thrown up, and the print code is showing ‘20091120’ which is today’s date ok.

All the buttons are showing the Add to Cart image, though…whereas by rights, with the dates of products all having expired, they should be whoing the Finished image.

??

Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

hmmm…that’s weird.

I just thought to change the date of one of the courses to a future date (20091124) and uploaded the file again. This now ac tually pulls in the ‘Finished’ image!!

So courses which have finished are showing the live ‘add to cart’ button, while the courses still running are showing the ‘finished’ button.

Back to front!!

???


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Oh, duh, it would have to be that simple, wouldn’t it. Change this line:

if($now > 20091115){ // the 16th of Nov, when the course is held

to this:

if($now < 20091115){ // the 16th of Nov, when the course is held

And you should be good.

Walter

On Nov 20, 2009, at 1:32 PM, hugh wrote:

hmmm…that’s weird.

I just thought to change the date of one of the courses to a future
date (20091124) and uploaded the file again. This now ac tually
pulls in the ‘Finished’ image!!

So courses which have finished are showing the live ‘add to cart’
button, while the courses still running are showing the ‘finished’
button.

Back to front!!

???


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

EURKEA!

Looks like we have liftoff, thanks Walter!

Only odd thing is the Finished button centreing correctly, but not the Add to Cart button - weird as they’re both being called by the same bit of code in the one markup item…??

Hugh


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options