picxx
Well-Known Member
I bl.a. norge og tyskland er det pålagt å legge ved angrefristskjema når man selger fysiske varer på nett. Mulig det finnes butikkløsninger hvor dette er implentert, men skal du bruke OsCommerce kan dette gjøres enkelt ved å legge til 2 kodesnutter i 2 filer.
All takk til nukleuz her på forumet for å ha ordnet med koden slik at det er mulig å benytte den.
Denne instruksjonen er testet på oscommerce 2.3
I fila /checkout_process.php
finn denne linjen
bytt ut med denne linjen
I fila includes/languages/XXX/checkout process.php
legg til denne koden før den siste ?>
Last opp fila Angrefristskjema.pdf i languagefolderen din.
(ja, denne må du lage selv)
All takk til nukleuz her på forumet for å ha ordnet med koden slik at det er mulig å benytte den.
Denne instruksjonen er testet på oscommerce 2.3
I fila /checkout_process.php
finn denne linjen
PHP:
tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
bytt ut med denne linjen
PHP:
tep_mail_pdf_anhang($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, DIR_WS_LANGUAGES . $language . "/" . "conditions.pdf", "application/pdf");
I fila includes/languages/XXX/checkout process.php
legg til denne koden før den siste ?>
PHP:
/**
* @author Joachim M. Giæver
* @access public
*
* osCommerce:
* BOC e-mail with attachment; tweaked version because the eregi-function in
* depreciated in newer PHP-version. We use stripos instead.
*
* @license WTFPL: http://en.wikipedia.org/wiki/WTFPL
* @version 1
*/
function tep_mail_pdf_anhang( $to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address, $file, $filetype ) {
// Return false because we're not allowed to send emails now...
if (SEND_EMAILS != 'true') return false;
// Create an array with values we want to validate withing the lookFor().
$Validate = array(
$to_name,
$to_email_address,
$email_subject,
$email_text,
$from_email_name,
$from_email_address
);
// Look for "Content-Type:"
if ( lookFor( 'Content-Type:', $Validate ) )
return false; // return false if there is a match in some values
// In orginal code you didn't check for \n and \r on $email_text, so we remove it!
$Remove = array_keys( $Validate, $email_text );
// If the array contained $email_text, and there is only one entry (otherwise there is something wrong)
if ( !empty( $Remove ) && count( $Remove ) == 1 )
unset( $Validate[ $Remove[0] ] );
// Look for "\n" and "\r" in values; except the $email_text hence to the comment above
if ( lookFor( "\n", $Validate ) || lookFor( "\r", $Validate ) )
return false; // return false if there are matches
/**
* Sooo, we reuse some of the original code; I just cleaned it....
*/
$message = new email( array( 'X-Mailer: osCommerce Mailer' ) );
$text = strip_tags( $email_text );
if ( EMAIL_USE_HTML == 'true' )
$message->add_html( $email_text, $text );
else
$message->add_text( $text );
$attachment = fread( fopen( $file, "r" ), filesize( $file ) );
$message->add_attachment( $attachment, Angrefristskjema, $filetype );
$message->build_message();
$message->send( $to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject );
// missing return statement....? What about:
// return $message->send( $to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject );
}
/**
* Look for a given statement withing an array
*
* @param string $LookFor
* @param array $Array
* @return boolean
*/
function lookFor( $LookFor, $Array ) {
// If the given array is empty, we return true which simulates a "match"
if ( empty ( $Array ) )
return true; // Here we should have thrown an exception instead, because this should not be empty!!!
// Loop through the array with all values
foreach ( $Array as $Str )
if ( stripos( $Str, $LookFor ) ) // Look for given criteria
return true; // Return true = match; which also stops further unecessary looping
// non matches... return false...
return false;
}
Last opp fila Angrefristskjema.pdf i languagefolderen din.
(ja, denne må du lage selv)
Sist redigert: