Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Coupons


boxtel

Recommended Posts

oh okayz.. now I know what you mean..

 

By the way.. I install the easy discount.. but I do not know how to insert the formula..

 

Lets say i want to insert this :

if ($cart->count_contents() > 5) {

$easy_discount->set('CQTY','Cart Quantity Discount',500);

} else {

$easy_discount->clear('CQTY');

}

 

Which file should I put in ?

 

Thank you.

 

Best Regards,

Alvin

Link to comment
Share on other sites

  • Replies 165
  • Created
  • Last Reply

Top Posters In This Topic

I have tried putting this

 

if ($cart->count_contents() > 5) {

$easy_discount->set('CQTY','Cart Quantity Discount',5);

} else {

$easy_discount->clear('CQTY');

}

 

into ot_easy_discount.php under the admin-->modules-->order total

 

and it doesnt work after i ordered 10 items.

Link to comment
Share on other sites

I have tried putting this

into ot_easy_discount.php under the admin-->modules-->order total

 

and it doesnt work after i ordered 10 items.

 

put the code in application_top.php somewhere after:

 

if (!tep_session_is_registered('easy_discount')) {

tep_session_register('easy_discount');

$easy_discount = new easy_discount();

}

Treasurer MFC

Link to comment
Share on other sites

Thanks for your reply..

 

Here is my code in application_top.php

 

 

// include shopping cart class

require(DIR_WS_CLASSES . 'shopping_cart.php');

 

// include easy discount products class

require(DIR_WS_CLASSES . 'easy_discount.php');

 

// include navigation history class

require(DIR_WS_CLASSES . 'navigation_history.php');

 

 

// create the shopping cart & fix the cart if necesary

if (tep_session_is_registered('cart') && is_object($cart)) {

if (PHP_VERSION < 4) {

$broken_cart = $cart;

$cart = new shoppingCart;

$cart->unserialize($broken_cart);

}

} else {

tep_session_register('cart');

$cart = new shoppingCart;

}

 

// include currencies class and create an instance

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

 

 

if (!tep_session_is_registered('easy_discount')) {

tep_session_register('easy_discount');

$easy_discount = new easy_discount();

}

 

if ($cart->count_contents() > 5) {

$easy_discount->set('CQTY','Cart Quantity Discount',5);

} else {

$easy_discount->clear('CQTY');

}

[/quote

 

I tried to order 10 items and it did not give me a discount..

 

Regards,

Alvin

Link to comment
Share on other sites

Hi Amanda,

 

Thanks for this contribution, I now have it working on my site, just the formatting of the text etc. to sort out but it is taking the correct discount off and it is all showing up so thanks very much!

 

If I can't figure out how to change the format of something I may scream for help, but again thanks for this contribution!

Link to comment
Share on other sites

put the code in application_top.php somewhere after:

 

if (!tep_session_is_registered('easy_discount')) {

tep_session_register('easy_discount');

$easy_discount = new easy_discount();

}

 

Alvinluo, I cannot seem to respond to your last post so I do it here.

 

You have the shopping cart display add-on for easy discount installed?

That should show all discounts issued via easy discount directly in the cart.

 

if the discount does not show at checkout confirmation, check the sort order of the modules, that gives problems sometimes.

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

 

Thanks for this contribution, I now have it working on my site, just the formatting of the text etc. to sort out but it is taking the correct discount off and it is all showing up so thanks very much!

 

If I can't figure out how to change the format of something I may scream for help, but again thanks for this contribution!

 

yes, I realise that I left the button "please wait" replacement code in the box:

 

echo tep_hide_session_id() . '<div class="hideMe" id="cp"><img src="images/button_please_wait.gif"></div><div class="showMe" id="cs">'.tep_image_submit('button_cash_in.gif', 'Cash in Coupon', ' onClick="visOn(\'cp\');visOff(\'cs\');" ').'</div>';

 

You need the associated javascript for that to work though.

 

just change that to :

 

echo tep_hide_session_id() . tep_image_submit('button_cash_in.gif', 'Cash in Your Coupon');

Treasurer MFC

Link to comment
Share on other sites

What should I add in shopping_cart.php ? i have tried to add

 

if ($cart->count_contents() > 5) {

$easy_discount->set('CQTY','Cart Quantity Discount',5);

} else {

$easy_discount->clear('CQTY');

}

 

somewhere bottom the shopping_cart.php and it appeared some errors..

 

this is the whole code for my shopping_cart.php

 

<?php

/*

$Id: shopping_cart.php,v 1.73 2003/06/09 23:03:56 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require("includes/application_top.php");

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

<table border="0" width="769" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" style="padding-bottom:3px; ">

<tr>

<td align="center">

<!-- body //-->

<table border="0" width="769" cellspacing="0" cellpadding="0">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top" style="padding:0px 4px; "><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>

<table border="0" width="100%" cellspacing="0" cellpadding="0" >

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php $info_box_contents = array();

$info_box_contents[] = array('text' => HEADING_TITLE); new infoBoxHeading($info_box_contents, true, true, false);?></td>

 

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>

</tr>

<tr>

<td height="430" class="infoBox1" valign="top">

<table border="0" width="100%" cellspacing="2" cellpadding="0" >

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>

</tr>

<?php

if ($cart->count_contents() > 0) {

?>

<tr>

<td style="padding:0px 4px; " valign="top">

<?php

$info_box_contents = array();

$info_box_contents[0][] = array('align' => 'left',

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_REMOVE);

 

$info_box_contents[0][] = array('params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_PRODUCTS);

 

$info_box_contents[0][] = array('align' => 'center',

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_QUANTITY);

 

$info_box_contents[0][] = array('align' => 'right',

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_TOTAL);

 

$any_out_of_stock = 0;

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

// Push all attributes information in an array

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

while (list($option, $value) = each($products[$i]['attributes'])) {

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix

from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

where pa.products_id = '" . $products[$i]['id'] . "'

and pa.options_id = '" . $option . "'

and pa.options_id = popt.products_options_id

and pa.options_values_id = '" . $value . "'

and pa.options_values_id = poval.products_options_values_id

and popt.language_id = '" . $languages_id . "'

and poval.language_id = '" . $languages_id . "'");

$attributes_values = tep_db_fetch_array($attributes);

 

$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];

$products[$i][$option]['options_values_id'] = $value;

$products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];

$products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];

$products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];

}

}

}

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

if (($i/2) == floor($i/2)) {

$info_box_contents[] = array('params' => 'class="productListing-even"');

} else {

$info_box_contents[] = array('params' => 'class="productListing-odd"');

}

 

$cur_row = sizeof($info_box_contents) - 1;

 

$info_box_contents[$cur_row][] = array('align' => 'center',

'params' => 'class="productListing-data" valign="top"',

'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

 

$products_name = '<table border="0" cellspacing="2" cellpadding="2">' .

' <tr>' .

' <td class="productListing-data" align="left"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .

' <td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>';

 

if (STOCK_CHECK == 'true') {

$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);

if (tep_not_null($stock_check)) {

$any_out_of_stock = 1;

 

$products_name .= $stock_check;

}

}

 

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';

}

}

 

$products_name .= ' </td>' .

' </tr>' .

'</table>';

 

$info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"',

'text' => $products_name);

 

$info_box_contents[$cur_row][] = array('align' => 'center',

'params' => 'class="productListing-data" valign="top"',

'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

 

$info_box_contents[$cur_row][] = array('align' => 'right',

'params' => 'class="productListing-data" valign="top"',

'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');

}

 

new productListingBox($info_box_contents);

?>

</td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td>

</tr>

<?php

if ($any_out_of_stock == 1) {

if (STOCK_ALLOW_CHECKOUT == 'true') {

?>

<tr>

<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></td>

</tr>

<?php

} else {

?>

<tr>

<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td>

</tr>

<?php

}

}

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main"><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?></td>

<?php

$back = sizeof($navigation->path)-2;

if (isset($navigation->path[$back])) {

?>

<td class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td>

<?php

}

?>

<td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<?php

} else {

?>

<tr>

<td align="center" class="main"><?php new infoBox(array(array('text' => TEXT_CART_EMPTY))); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<?php

}

?>

</table></td></tr>

</table></form></td>

<!-- body_text_eof //-->

<td width="<?php echo BOX_WIDTH_RIGHT; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH_RIGHT; ?>" cellspacing="0" cellpadding="0">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right1.php'); ?>

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

</td>

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Please let me know what and where should I add the easy discount code..

 

Really thank you Amanda.

 

Regards,

Alvin

Link to comment
Share on other sites

You need to add:

 

after: require("includes/application_top.php");

include_once (DIR_WS_FUNCTIONS.'easy_discount.php');

 

 

in between the head tags add:

<script language="javascript"><!--
function session_win2() {
 window.open("<?php echo tep_href_link(FILENAME_INFO_COUPON); ?>","info_coupon"," height=360,width=700,toolbar=no,statusbar=no,scrollbars=yes").focus();
}
function autotab(original,destination){if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))destination.focus()}
//--></script>

 

after:<td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td>

</tr>

 

add:

<?php
if ($easy_discount->count() > 0) {
 echo easy_discount_display();
 echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</td></tr>';
} 
?>

 

Also add:

 

if ($cart->count_contents() > 5) {
 $easy_discount->set('CQTY','Cart Quantity Discount',500);
} else {
 $easy_discount->clear('CQTY');
}

 

into the page somewhere, above the last bit of code worked for me. I really don't know much about coding but following Amanda's instructions this is where I put the code and it worked for me. HTH

Link to comment
Share on other sites

Hey Amanda, I have tried to install new OSC..and your scripts worked perfectly.. I am very sorry to trouble you so much. I will try to find out what is my old OSC problems.. I must really thank you for helping me so much. Thanks again.

 

Regards,

Alvin

Link to comment
Share on other sites

YAY ! I FINALLY MANAGED TO GET IT..

 

However there is a slightly problem..

 

the total and subtotal position abit weird.. it appeared like this

 

 

Sub-Total: RM70.00

Cart Quantity Discount: -

RM17.50

Total: RM52.50

 

 

Any idea how to edit this?

 

Regards,

Alvin

Link to comment
Share on other sites

Hey turner2000, thanks for your reply.. My discount is working now =).

 

I cant figure out what's wrong with my easy coupons. Admin tools works fine.. when customer bought a product the coupon code got generated. But when i apply that code it doesnt give me that discount. When I hit the "CASH IN" button it dint discount the price and it looks like just refreshing the page.

 

Which file I did wrong ? May be I can paste the code here..

 

THanks in advance.

 

Regards,

Alvin

Link to comment
Share on other sites

I have solved my problems. I just found out that I forgot to install the easy discount in my modules. :blush:

 

Very thanks to you guys helping me so much. Thank you and Have a nice day !

 

Regards,

Alvin

 

I had the same problem as you Alvinluo. I didnt install the addon scripts - damnit! so silly of me. been spending weeks on this.

 

I'm just trying to work out how to format the script to line up now. got the text / font changed. now just need to line it up.

Link to comment
Share on other sites

Hey ! This is the last problem I have.

 

untitledlq5.jpg

 

How should I change this position?

 

Thanks in advance.

 

Regards,

Alvin

 

 

Fixed!

 

I just put a <table> </table> around the php script

 

File: catalog/shopping_cart.php

 

<table>

<?php
if ($easy_discount->count() > 0) {
 echo easy_discount_display();
 echo '<tr><td align="right" class="main">'.SUB_TITLE_TOTAL.'</td>
 <td align="right" class="main"><b>'.$currencies->format(($cart->show_total() - $easy_discount->total())).'</b></td></tr>';
} 
?>

</table>

Link to comment
Share on other sites

OMG echolalia !!! YOU ARE THE MAN !! THX ALOT !!

 

Haha.. well Amanda's scripts are so useful..thx alot !!! I am really noob at PHP scripts.. =(

 

Btw is there any way to test out PHP without uploading to the server?

 

Regards,

Alvin

Link to comment
Share on other sites

OMG echolalia !!! YOU ARE THE MAN !! THX ALOT !!

 

Haha.. well Amanda's scripts are so useful..thx alot !!! I am really noob at PHP scripts.. =(

 

Btw is there any way to test out PHP without uploading to the server?

 

Regards,

Alvin

 

Thanks Alvinluo, thou i'm yet to celebrate.

 

My shopping_cart.php works fine, the discount code works etc... however once i start to checkout, the prices are back to normal. I've added the coupon mod to every page in the check out, the shopping cart is displayed etc... however the prices are as normal. any suggestions?

Link to comment
Share on other sites

Lol I was having the problem same with you last time. Haha.. I dint know the setup is so easy and I was like finding it so difficult..haha..great job Amanda. Echolia do you mind to share your site with us? Os commerce can design alot of style and I would like to see more of it.. hehe..

 

btw here is my site.. feel free to give any comments.. I dont mind receiving harsh comments..the pictures look weird and I gonna make it change it and make it smaller..=)

 

My Webpage

 

Regards,

Alvin

Link to comment
Share on other sites

Lol I was having the problem same with you last time. Haha.. I dint know the setup is so easy and I was like finding it so difficult..haha..great job Amanda. Echolia do you mind to share your site with us? Os commerce can design alot of style and I would like to see more of it.. hehe..

 

btw here is my site.. feel free to give any comments.. I dont mind receiving harsh comments..the pictures look weird and I gonna make it change it and make it smaller..=)

 

My Webpage

 

Regards,

Alvin

 

Hey Alvin,

 

At the moment the site is a basic straight out of the box os commerce page. I'm working on a 'Product of the day' for a client who wants a new product to go on the site every day and only be up there for 7 days. still got a bit to work on it. gotta work out how to get the product to be added automatically etc... fill free to add any suggestions. (i can send u the link im pm).

 

Really impressive site - if u mind me asking - did u design that urself? only criticism i can offer - at the bottom of the site - the "Designed By AlvinLuo" - the link is wrong, you have .com.com

 

Last thing i have to work out with Easy Coupon - one of the things i wanna do - say if u have a promo running on radio / print. How do you get it so there is no set limit to how many times someone can use the code?

 

Cheers!

Edited by echolalia
Link to comment
Share on other sites

Hey Alvin,

 

At the moment the site is a basic straight out of the box os commerce page. I'm working on a 'Product of the day' for a client who wants a new product to go on the site every day and only be up there for 7 days. still got a bit to work on it. gotta work out how to get the product to be added automatically etc... fill free to add any suggestions. (i can send u the link im pm).

 

Really impressive site - if u mind me asking - did u design that urself? only criticism i can offer - at the bottom of the site - the "Designed By AlvinLuo" - the link is wrong, you have .com.com

 

Last thing i have to work out with Easy Coupon - one of the things i wanna do - say if u have a promo running on radio / print. How do you get it so there is no set limit to how many times someone can use the code?

 

Cheers!

 

Last thing i have to work out with Easy Coupon - one of the things i wanna do - say if u have a promo running on radio / print. How do you get it so there is no set limit to how many times someone can use the code?

 

well, basically every coupon can only be used once as it is related to the order on which it was used.

Still, you can make all coupons last forever until you yourself set the coupon to used in admin or the end date is reached if you have set one.

You can do this by commenting out this code in checkout_process.php which normally sets the used coupon to used.

 

// set the current coupon code to used

if (tep_session_is_registered('couponcode')) tep_db_query("update " . TABLE_COUPONS . " set used = 1, orders_id_used = ".$insert_id." where code = '".$couponcode['code']."'");

 

but remember that without this you will have no tracking in easy coupons on who used the coupon and how many times.

Edited by boxtel

Treasurer MFC

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...