Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Discount


boxtel

Recommended Posts

Here are the errors I'm getting:

Warning: main(DIR_WS_FUNCTIONSeasy_discount.php): failed to open stream: No such file or directory in /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php on line 13

 

Warning: main(): Failed opening 'DIR_WS_FUNCTIONSeasy_discount.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php on line 13

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php:13) in /home/.charmian/moosedog/laurelsstitchery.com/catalog/includes/functions/sessions.php on line 97

Fatal error: Call to a member function on a non-object in /home/.charmian/moosedog/laurelsstitchery.com/catalog/shopping_cart.php on line 166

 

you include the function file before application_top and as such DIR_WS_FUNCTION has not been defined yet.

Treasurer MFC

Link to comment
Share on other sites

Amanda, Phil,

 

Amanda thanks for the logoff tip. I looked at the relevant fields and added but did not work. I am using Phil's code for the promo code on the shopping cart screen

 

<?php
include_once(DIR_WS_FUNCTIONS.'easy_discount.php');
$easy_discount->reset();
if(!(isset($promo_code))) {$promo_code=0;}
if($promo_code == 'SPECIAL')
{
$easy_discount->add('ECD','Early Customer Discount',0);
}
?>

 

As you can see I tried to reset the promo_code field but that did not work either. So everytime a customer comes into the shopping cart, who previously entered SPECIAL in the promo code field, has this field automatically populated with SPECIAL and the discount applies.

 

Obviously not what I want.

 

Any suggestions would be appreciated.

 

Regards

Neil

Link to comment
Share on other sites

Amanda, Phil,

 

Amanda thanks for the logoff tip. I looked at the relevant fields and added but did not work. I am using Phil's code for the promo code on the shopping cart screen

 

<?php
include_once(DIR_WS_FUNCTIONS.'easy_discount.php');
$easy_discount->reset();
if(!(isset($promo_code))) {$promo_code=0;}
if($promo_code == 'SPECIAL')
{
$easy_discount->add('ECD','Early Customer Discount',0);
}
?>

 

As you can see I tried to reset the promo_code field but that did not work either. So everytime a customer comes into the shopping cart, who previously entered SPECIAL in the promo code field, has this field automatically populated with SPECIAL and the discount applies.

 

Obviously not what I want.

 

Any suggestions would be appreciated.

 

Regards

Neil

 

at logoff:

 

tep_session_unregister('promo_code');

Treasurer MFC

Link to comment
Share on other sites

at logoff:

 

tep_session_unregister('promo_code');

 

 

it would even be better not to register promo_code in the session, it is not necessary.

 

on the page you simply check the field from the form and if ok, issue the discount and that's the end of it.

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

 

Finally got everything working. Took me a lot longer than it should have, but my skills are newbie-like. Thanks for your contribution and all your help. I checked out your website, it's very impressive. Good work!

 

Thanks again!!

Link to comment
Share on other sites

it would even be better not to register promo_code in the session, it is not necessary.

 

on the page you simply check the field from the form and if ok, issue the discount and that's the end of it.

 

Thanks Amanda.

 

Now I have another question. What is to stop people viewing the code for the shopping cart page, seeing the discount code and then using that to get cheaper goods?

 

I don't think you can stop users using "edit with Notepad" on a webpage can you.

 

Regards

Neil

Link to comment
Share on other sites

Thanks Amanda.

 

Now I have another question. What is to stop people viewing the code for the shopping cart page, seeing the discount code and then using that to get cheaper goods?

 

I don't think you can stop users using "edit with Notepad" on a webpage can you.

 

Regards

Neil

 

nobody can see your code thru the webserver, only what you echo out.

Treasurer MFC

Link to comment
Share on other sites

Thanks for the help! :) It seems to be working now. Can you help me with the code to put in to give new customers free shipping? I need someone to hold my hand and tell me step-by-step what to do. Thanks! :)

 

you include the function file before application_top and as such DIR_WS_FUNCTION has not been defined yet.

Laurel

Link to comment
Share on other sites

Thanks for the help! :) It seems to be working now. Can you help me with the code to put in to give new customers free shipping? I need someone to hold my hand and tell me step-by-step what to do. Thanks! :)

 

osc already has its default free shipping facility in admin and there are several contributions which do that. Easy Discount is not the facility for that.

Treasurer MFC

Link to comment
Share on other sites

Where is this located in Admin?

 

It is always a good tactic to check out all available default settings in admin before you start installing contributions.

 

the default free shipping setting is under modules->order total.

Treasurer MFC

Link to comment
Share on other sites

How do I set that module up for FREE SHIPPING FOR NEW CUSTOMERS (FIRST ORDER) ONLY? I don't see that option available.

 

It is always a good tactic to check out all available default settings in admin before you start installing contributions.

 

the default free shipping setting is under modules->order total.

Laurel

Link to comment
Share on other sites

Trying to figure out the code to give a discount off a particular product if it's ordered in bulk.

 

For example, If a customer has 5 or more of Product A in their cart, give them 10% off their total for product A. Any other products in their cart should not be discounted, if they have less than 4.

 

 

Further Example:

 

Widget #1 Quantity 5, price $10.00 each = $50.00

Widget #2 Quantity 8, price $10.00 each = $80.00

Widget #3 Quantity 1, price $10.00 each = $10.00

 

Discount of 10% should only be applied to Widget #1 and Widget #2 since the number of that item ordered were 5 or more for those items only.

 

Ideas?

 

Thanks.

Link to comment
Share on other sites

Trying to figure out the code to give a discount off a particular product if it's ordered in bulk.

 

For example, If a customer has 5 or more of Product A in their cart, give them 10% off their total for product A. Any other products in their cart should not be discounted, if they have less than 4.

Further Example:

 

Widget #1 Quantity 5, price $10.00 each = $50.00

Widget #2 Quantity 8, price $10.00 each = $80.00

Widget #3 Quantity 1, price $10.00 each = $10.00

 

Discount of 10% should only be applied to Widget #1 and Widget #2 since the number of that item ordered were 5 or more for those items only.

 

Ideas?

 

Thanks.

 

$easy_discount->reset();

$products = $cart->get_products();

$n=sizeof($products);

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

if ($products[$i]['quantity']) >= 5) {

$easy_discount->set($products[$i]['id'],'Bulk Discount '.$products[$i]['name'],$products[$i]['price']*$products[$i]['quantity']*0.1);

else {

$easy_discount->clear($products[$i]['id']);

}

}

Treasurer MFC

Link to comment
Share on other sites

How do I set that module up for FREE SHIPPING FOR NEW CUSTOMERS (FIRST ORDER) ONLY? I don't see that option available.

 

no, that is not one of the options. You would have to change some code in checkout_shipping and the ot_shipping module for that. Look at the conditions used there and add your own based on first customer.

Treasurer MFC

Link to comment
Share on other sites

Like I said, I have no idea how to do that and there are no instructions with the contribution. Can you help me at all with this?

 

no, that is not one of the options. You would have to change some code in checkout_shipping and the ot_shipping module for that. Look at the conditions used there and add your own based on first customer.

Laurel

Link to comment
Share on other sites

I assume the code will look something like this:

if (first time customer) $easy_discount->add('First timer Discount',$order->info['subtotal']/4);
discount of 25% of the order subtotal if first time customer

I need to know which parts of this to change for what I want to do. I want the cart to look at the customer's order history and see if they have any previous orders. If they have previous orders = no discount. If this is their first order = $2 off (equivalent of free shipping to USA).

 

Would this code work for what I want to do?

if (new customer) $easy_discount->add('New Customer Discount',$order->info['subtotal']-2);

Also, I have the following questions:

1. Where do I paste the code (which file and where in the file)?

2. Do I need to add an 'else' or 'reset' statement of any kind? If so, which file and where?

 

Thanks! :)

 

I couldn't find instructions on the code to offer free shipping on a customer's first order. I know pretty much nothing about php coding, so I need some help.

Laurel

Link to comment
Share on other sites

I assume the code will look something like this:

if (first time customer) $easy_discount->add('First timer Discount',$order->info['subtotal']/4);
discount of 25% of the order subtotal if first time customer

I need to know which parts of this to change for what I want to do. I want the cart to look at the customer's order history and see if they have any previous orders. If they have previous orders = no discount. If this is their first order = $2 off (equivalent of free shipping to USA).

 

Would this code work for what I want to do?

if (new customer) $easy_discount->add('New Customer Discount',$order->info['subtotal']-2);

Also, I have the following questions:

1. Where do I paste the code (which file and where in the file)?

2. Do I need to add an 'else' or 'reset' statement of any kind? If so, which file and where?

 

Thanks! :)

 

ah ok, but this is not free shipping, this is giving a discount of an equal amount to shipping. They may amount to the same result (money-wise) but they are two very different things.

 

let me get back to you about this.

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

 

This contribution seems to be very much somthing I would like to offer to the customers of my store. My only reservation about this is becuase I have CCGV installed.

 

MY GOAL.. is to give all customers 10% off on their first order.

 

MY FEAR...with this is that if I release a coupon code that say gives $5 off a $30 product, the the customer is already getting around 15% off... and if they use it on their first purchase it they will end up getting 25% off.

 

MY QUESTION...is it possible to allow the customer to only get one (the greater of the two discounts) but not both discounts?

 

Thanks,

 

Nate

Link to comment
Share on other sites

Im back, hehe.

 

I have run in to a problem.

 

I have it set up so customers get 10% off their First order.

 

Everything was working fine with the "First Customer" fix that i grabbed from webexceed, until i implemented the 10% discount part.

This is my current code that i have in shopping_cart.php

 

<?php
include_once(DIR_WS_FUNCTIONS.'easy_discount.php');
$easy_discount->reset();
if($first_time_customer)
{
if ($cart->count_contents() > 0) {
$easy_discount->add('NEW','10% Off New Customer',$cart->show_total()*0.10);
} else {
$easy_discount->remove_type('NEW');
}
}
?>

 

 

Customers are still recieving the 10% AFTER placing their first order.

I had this problem before, but it got corrected. After i placed the

$easy_discount->add('NEW','10% Off New Customer',$cart->show_total()*0.10);

in there to take 10% off, it doesn't work correctly anymore (keeps giving the 10% discount even if the customer has already ordered).

 

If i take that out and replace it with the default code

$easy_discount->add('1STCUST', 'Welcome Discount', 1);

It works properly by not giving customers any discount who have already placed an order.

 

 

Everything was working great until i made the discount 10% instead of (example) $5.00.

 

What can I do here to fix it?

Link to comment
Share on other sites

Im back, hehe.

 

I have run in to a problem.

 

I have it set up so customers get 10% off their First order.

 

Everything was working fine with the "First Customer" fix that i grabbed from webexceed, until i implemented the 10% discount part.

This is my current code that i have in shopping_cart.php

 

<?php
include_once(DIR_WS_FUNCTIONS.'easy_discount.php');
$easy_discount->reset();
if($first_time_customer)
{
if ($cart->count_contents() > 0) {
$easy_discount->add('NEW','10% Off New Customer',$cart->show_total()*0.10);
} else {
$easy_discount->remove_type('NEW');
}
}
?>

Customers are still recieving the 10% AFTER placing their first order.

I had this problem before, but it got corrected. After i placed the

$easy_discount->add('NEW','10% Off New Customer',$cart->show_total()*0.10);

in there to take 10% off, it doesn't work correctly anymore (keeps giving the 10% discount even if the customer has already ordered).

 

If i take that out and replace it with the default code

$easy_discount->add('1STCUST', 'Welcome Discount', 1);

It works properly by not giving customers any discount who have already placed an order.

Everything was working great until i made the discount 10% instead of (example) $5.00.

 

What can I do here to fix it?

 

my guess is that you do not set the $first_time_customer variable to false after the first order has been recorded and as such that discount is added again and again.

 

$easy_discount->reset(); clears all discounts so if a discount still shows up, then that variable is still set to true, in other words, the condition for giving the discount has not changed.

Treasurer MFC

Link to comment
Share on other sites

Hi Amanda,

 

This contribution seems to be very much somthing I would like to offer to the customers of my store. My only reservation about this is becuase I have CCGV installed.

 

MY GOAL.. is to give all customers 10% off on their first order.

 

MY FEAR...with this is that if I release a coupon code that say gives $5 off a $30 product, the the customer is already getting around 15% off... and if they use it on their first purchase it they will end up getting 25% off.

 

MY QUESTION...is it possible to allow the customer to only get one (the greater of the two discounts) but not both discounts?

 

Thanks,

 

Nate

 

ofcourse you can, even with other contributions you can construct things like :

 

suppose easy_discount has set a discount for product 12 like :

 

$easy_discount->set('12', 'Discount for product 12', 200);

 

if you then determine a larger discount for that product by whatever contribution you can say:

 

with easy discount itself you just use the set command again as that overwrites the discount with the same name:

 

$easy_discount->set('12', 'Discount for product 12', 200);

 

$easy_discount->set('12', 'Discount for product 12', 400);

 

only leaves 1 discount recorded of 400

 

$easy_discount->set('12A', 'Discount for product 12', 200);

 

$easy_discount->set('12B', 'Discount for product 12', 400);

 

would leave 2 discount records totalling 600 for prodct 12

 

 

 

with other contributions giving the new discount:

 

if (new discount for product 12 > $easy_discount->discounts['12']['amount'])

$easy_discount->clear('12');

}

 

this would clear the easy_discount for product 12 if a larger discount is determined by whatever means.

 

so it is just a matter of using the discount name field wisely.

 

 

 

 

 

 

that would

Treasurer MFC

Link to comment
Share on other sites

ah ok, but this is not free shipping, this is giving a discount of an equal amount to shipping. They may amount to the same result (money-wise) but they are two very different things.

 

let me get back to you about this.

 

well, I still believe that you should give free shipping using that facility but ok.

 

like stated, you ca use any condition for applying discounts as long as you have the valid information on which you base those conditions. In this code:

 

if (new customer) $easy_discount->set('NCD', 'New Customer Discount',$order->info['subtotal']-2);

 

you take the subtotal of the order, substract 2 (local currency) and register that as the discount.

as in:

 

item: part 1 US$50.00

Subtotal: US$50.00

Discount: - US$48.00

Total: US$2.00

 

This means that the order object needs to exist and therefore the customer has to have pressed checkout at least once. So the appropriate place would be checkout_shipping.php.

 

As the condition cannot be changed by the customer other than ordering, there is no need for an else statement, just the usual $easy_discount->reset(); after $cart->reset(); in checkout_process to clear the discount container.

 

And do not forget to set $first_time_customer to false after the order.

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...