Jump to content

new script


Guest black76

Recommended Posts

Guest black76

Hei!

I would appreciatte some help!!

I have this php script that I want to include in my orderform.tpl. This script will allow me to include a due date to pay to tell when the product should be paid but the problem is I dont know where to put this script.

Does anybody know how to add new php scripts ???

function calcduedate($datecalc,$duedays)

{

$i = 1;

while ($i <= $duedays)

{

$datecalc += 86400; //Add a day.

$date_info = getdate( $datecalc ) ;

if (($date_info["wday"] == 0) or ($date_info["wday"] == 6) )

{

$datecalc += 86400; // Add a day.

continue;

}

$i++;

}

return $datecalc ;

}

Where should I put this script ?

Link to comment
Share on other sites

Guest degsey69

Generaly you do not add php code into tpl files, pm markscarts or convict, they may help you or you can ask for help in the cubecart.org forum in the programming section. :D

Link to comment
Share on other sites

Guest kieran

Yes, open them in notepad name them file.php. Then upload, to include the file will be something different, because .tpl is just a rich text format.

Link to comment
Share on other sites

What you'll have to do is add your PHP code to the cart.php file, then add a line after it to assign the result to a template tag. After that, then all you have to do is place the new template tag where you want it to show up.

For example:

function calcduedate($datecalc,$duedays)

{

$i = 1;

while ($i <= $duedays) 

{

$datecalc += 86400; //Add a day.

$date_info = getdate( $datecalc );

if (($date_info["wday"] == 0) or ($date_info["wday"] == 6) )

{

$datecalc += 86400; // Add a day.

continue;

}

$i++;

}

return $datecalc;

}



$view_cart->assign("DUEDATE", calcduedate($datecalc, $duedays));




Now you have a template tag {DUEDATE} that you can add to the cart template(s).



I suspect that there's more to your scenario than just getting the calculation into the template.  I'm guessing that you'll need to pull the variables from the database.  If this number is to be different for each product, then you'll have to add a field to the product table and include the logic in the cart.php file to pull that data.





If the Due Date is to be shown only in certain conditions, then you will need to do the tag assignment as such:




$duedate = calcduedate($datecalc, $duedays)

if($duedate > 0) {

$view_cart->assign("DUEDATE",$duedate);

$view_order->parse("view_cart.cart_true.due_date"); }




And then in the cart.tpl, you'll have to add your new tag as:




<!-- BEGIN: due_date -->

{DUEDATE}

<!-- END: due_date -->

CubeCart uses the XTemplate template engine. You can learn all about it from http://www.phpxtemplate.org.

Or, you can do what I did and study the CubeCart PHP code. I'm not a programmer, but getting closer every day.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...