Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Discount


boxtel

Recommended Posts

I've had a problem with this contribution which I have now (hopefully) resolved - sounds like the same problem as posted above.

 

If I applied discounts in checkout_confirmation.php they showed in the order total. If the customer checked out using paypal all was fine, if they used an alternative method (in my case Sage Pay Server) the discount was lost - weird.

 

If I applied discounts elsewhere they applied (I know because ai put a bit of code in the footer) but were lost by the tme the shopper got to the checkout_confirmation.php page.

 

ANyway I tracked the problem down I was using the 18 Aug 2009 version by yesudo that fixes a session error. I've searched and couldn't find any mention in the thread of this error. I followed the original install insructions and this fixed everything.

 

In short

 

In application_top.php the code I used is...

 

  if (!tep_session_is_registered('easy_discount')) {
 tep_session_register('easy_discount');
 $easy_discount = new easy_discount();
 } 

 

not...

 

  if (!tep_session_is_registered('easy_discount')) {
 tep_session_register('easy_discount');
}
 $easy_discount = new easy_discount();

 

 

Well it worked for me - hope this saves someone some time...can't find any problems with doing this either - fingers crossed..

Rob

Sorry to bring this old thread back, I have installed this contribution, the same as mentioned previously I am able to see the discount applied in the shopping cart, however on the Checkout_confirmation it does not apply the discount. I have my discount condition inside the include/Application_top.php. Any help will be greatly appreciated.

Link to comment
Share on other sites

Be sure you have enabled the module in admin->Modules and its sort order is correct.

 

It shows Active, and for sort order it shows 2. Is that what it should have for sort order?

 

EDIT: I got it, i set the sort order to 0 and works now. Thank you very much. Anything important I should know about sort order and this kind of addon? if you dont mind sharing?

Edited by streetzlegend
Link to comment
Share on other sites

I have another question:

 

Say I have two total items in the shopping cart, but I only want to apply a 50% discount on the second item. How can I pick out that second item price from the array?

 

I was thinking of doing something like this: $products = $cart->get_products();

Then do an if statement: if ($cart->count_contents() > 1), then $products[1]['_DONT_KNO_WAT_TO_PUT HERE__'] = $ItemToDiscount //gets second's item price

 

Then $easy_discount->set('CQTY','Cart Quantity Discount',ItemToDiscount*0.50);

 

Any suggestions as to how I can get the price of an item from the array? I know for product shipping I can get it with products_ship_price, but dont know as for the actual price.

Link to comment
Share on other sites

What you are doing is correct approach. $products['final_price'] will have the price. Look at that funtion in includes/classes/shopping_cart.php for all of the fields.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

What you are doing is correct approach. $products['final_price'] will have the price. Look at that funtion in includes/classes/shopping_cart.php for all of the fields.

Thank you very much that worked.

 

I did a loop with the total count of items, so that it puts all the prices into an array, such as:

$prices_array[$xy] = $cart->products[$xy]['final_price'];

 

The new problem I am having is that, if you select the same product more than once, although the count records that there is an extra product, it does not get the price of all. for example if i sell books, and I add 4 of the same exact book, it returns: Array ( [0] => 99.5 [1] => [2] => [3] => ). only shows price for the first, then blank for the other 3 indexes. Any suggestions?

Link to comment
Share on other sites

Thank you very much that worked.

 

I did a loop with the total count of items, so that it puts all the prices into an array, such as:

$prices_array[$xy] = $cart->products[$xy]['final_price'];

 

The new problem I am having is that, if you select the same product more than once, although the count records that there is an extra product, it does not get the price of all. for example if i sell books, and I add 4 of the same exact book, it returns: Array ( [0] => 99.5 [1] => [2] => [3] => ). only shows price for the first, then blank for the other 3 indexes. Any suggestions?

Use the quantity field in that array (final_price * qty).

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 1 month later...

I'm using this code:

 

if ($cart->in_cart(30)) {
	$easy_discount->add('P30','1062 Discount',200);
} else {
	$easy_discount->remove_type('P30');
	}
}

 

However it's not showing up. I was thinking that perhaps my product ID is incorrect but I'm unable to determine 100% what it is?

 

Based on the links I'm clicking in my store, (I only have 3 products) they appear to be ID's 28, 29 and 30. Do categories effect this at all?

Link to comment
Share on other sites

I'm using this code:

 

if ($cart->in_cart(30)) {
	$easy_discount->add('P30','1062 Discount',200);
} else {
	$easy_discount->remove_type('P30');
	}
}

 

However it's not showing up. I was thinking that perhaps my product ID is incorrect but I'm unable to determine 100% what it is?

 

Based on the links I'm clicking in my store, (I only have 3 products) they appear to be ID's 28, 29 and 30. Do categories effect this at all?

 

It would appear that my product ID's are correct. But when using them with Product Attributes my ID becomes a very long string. I only wish to check the first 2 spaces of my ID, using substr I'm unable to do so.

Link to comment
Share on other sites

Hi guys,

 

been attempting to get this working, however have ran into an issue that i can't seem to fix.

I have installed the application_top.php as per instructions

Uploaded files

installed module

installed addons

 

This is my code in shopping_cart

 

  require("includes/application_top.php");
 include_once (DIR_WS_FUNCTIONS.'easy_discount.php');

 $easy_discount->reset();

 if ($cart->count_contents() > 0) {
   include(DIR_WS_CLASSES . 'payment.php');
   $payment_modules = new payment;
 }

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

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

   if ($cart->count_contents() == 2) {
   $easy_discount->add('QD','Cart discount',4.9); 
} else {  
   $easy_discount->clear('QD');
}

 

Works fine however in checkout_confirmation i have the standard pricing with no discount.

 

I have fiddled with the sort order to no prevail, and yes it is installed.

 

Any ideas?

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Hi, is this thread still active? Excuse my mediocre english, I´m (obviously) not a native speaker.

 

I have a small problem with easy discount 1.2. It works just fine (on oscommerce 2.3.3.), but I was wondering if there is a way to check not the total contents of the shopping cart, but the number of items from ONE CATEGORIE in the shopping cart. We are trying to sell tickets for a theatre-group and give discounts for groups if someone purchases more than 20 tickets for ONE DATE. So far I can only give a discount on more than 20 tickets in the shopping cart, even if they only buy 2 tickets for 10 different dates (which normally would not get them any discount). Anyone got a tip for me???

 

To make it more difficult... if someone purchases 20 tickets for one date and 10 tickets for another, I need the discount to ONLY include the categorie that has >20 purchases, while the tickets from the other category (=date) are checked out without discount. Is that possible at all, or is our plan for an online-shop doomed??? :o)

 

Thanks in advance,

Verena (shuefly80)

Link to comment
Share on other sites

The thread is still active but the author of the package doesn't visit here anymore. At least, I haven't noticed her posts.

 

You can setup any discount you like using this contribution but you have to create the code to do that. To select by category, you would have to get the category of the product in the cart and compare against that. My Daily Specials contribution uses this contribution to do that. If you can figure out the code, the way to do it is in there. Or you could just install that contribution.

 

For the date limit, that is possible. You would need to check the quantity of each category and set the discount for the one that is greater.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 3 years later...

hi, I was testing this addon, and applying a 10% discount if customers order 3 or more items.

 

the discount is applied, but the calculated VAT is based upon the original value of the goods, not the discounted value.

How can this is rectified? 

 

Also, when payment is made using the paypal app, the itemised list of goods being bought is not listed.  Instead it states just one item, and shows the value of the goods and the VAT which is upon the undiscounted value of goods.

 

again how can this be rectified?

 

note, if no discount is applied then paypal lists the itemised goods

 

Mike 

osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!)

Link to comment
Share on other sites

It sounds like your formula is not correct. You may have something like

 

if (count == 3) {

total = total - ( total x 10%)

total = calculate tax (total)

}

 

while it should be something like

 

if (count == 3) {

 discount price = regular price - (regular price x 10%)

total = calculate tax (discount price)

}

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@@Jack_mcs

your assumption sounds right, but I thought easy discount took this into consideration

I've added this code in shopping_cart.php

 

// Start easy discount
if ($cart->count_contents() > 2) {
$easy_discount->set('CART','Discount for 3 or more items',$cart->show_total()*0.1);
} else {
$easy_discount->clear('CART');
}
// end easy discount

 

which I thought would adjust the sub-total (which it does) and the tax would be calculated accordingly, using the new sub-total(which it doesn't)

 

any thought please?

 

Mike

osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!)

Link to comment
Share on other sites

That code is just creating the discount on the total of the cart, which has the tax already calculated. I think you will need to use the get_products function and then go through the returned array to get the prices without the tax. Something like the following, untested, code:

if ($cart->count_contents() > 2) {
 $products = $cart->get_products();
 $ttl = 0;
 foreach $products as $prod) {
     $ttl += $prod['price'];
 }
 $easy_discount->set('CART','Discount for 3 or more items',$ttl*0.1);
 } else {

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

hi, I was testing this addon, and applying a 10% discount if customers order 3 or more items.

 

the discount is applied, but the calculated VAT is based upon the original value of the goods, not the discounted value.

How can this is rectified? 

 

Also, when payment is made using the paypal app, the itemised list of goods being bought is not listed.  Instead it states just one item, and shows the value of the goods and the VAT which is upon the undiscounted value of goods.

 

again how can this be rectified?

 

note, if no discount is applied then paypal lists the itemised goods

 

Mike 

 

What about your order total module sort order? I'm not sure you mentioned it....

 

Subtotal should be 1 and this module should be 2....

Link to comment
Share on other sites

Also, when payment is made using the paypal app, the itemised list of goods being bought is not listed.  Instead it states just one item, and shows the value of the goods and the VAT which is upon the undiscounted value of goods.

That's how the newest paypal modules work if a third party Order Total module is used. No details are shown, only order total amount. See docuimentation.

The wrong VAT (Order Total) value is due to the same problem like in the calculation in the confirmation page. Once it is fixed there it will apply correct total also in PayPal.

Edited by raiwa
Link to comment
Share on other sites

What about your order total module sort order? I'm not sure you mentioned it....

 

Subtotal should be 1 and this module should be 2....

I have the sort order as you state, the easy discount module is after subtotal, I'll investigate further using the suggested code above.

 

@@raiwa, thanks for the info, I missed that in the documentation

osC CE live - developing osC Phoenix adding modules with no core changes(awesome and easy!)

Link to comment
Share on other sites

  • 3 months later...

Hi there

I have been playing with this addon and have it working it is very cool. 

The final piece of the puzzle is trying to get the column shopping box working as it is an old MS2 code The original box code is below but how do I include  the function easy_discount into the box module.

Doug

Shopping cart info box addon:

in includes/boxes/shpping_cart.php

add in top:

<?php
include (DIR_WS_FUNCTIONS.'easy_discount.php');
?>


after :

    $info_box_contents[] = array('align' => 'right',
                                 'text' => $currencies->format($cart->show_total()));

add:

if ($easy_discount->count() > 0) {
  $info_box_contents [] = array('align' => ' right ',
                                'text' => 'Discounts: <font color="red">- '.$currencies->format((easy_discount_total())).'</font>');
  $info_box_contents [] = array('align' => ' right ',
                                'text' => 'Total: '.$currencies->format(($cart->show_total() - easy_discount_total())));
} 

Link to comment
Share on other sites

Sorry realized I described this very badly.

 

I have the main part of the code working very well on a BS Gold site .

I have been trying to get the shopping cart box which sits in one of the columns working.

So trying to upgrade it to the latest standards.

The original code from the old instructions is pasted above.

I am getting all sorts of errors like

undefined functions 

call to non member function.

So I see that I am not calling functions but I am unsure how to go about this in the new box modules.

If anyone is able to turn the code above into a new box module it would be much appreciated.

Doug

 

This is what I have so far

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  class bm_shopping_cart {
    var $code = 'bm_shopping_cart';
    var $group = 'boxes';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function bm_shopping_cart() {
      $this->title = MODULE_BOXES_SHOPPING_CART_TITLE;
      $this->description = MODULE_BOXES_SHOPPING_CART_DESCRIPTION;

      if ( defined('MODULE_BOXES_SHOPPING_CART_STATUS') ) {
        $this->sort_order = MODULE_BOXES_SHOPPING_CART_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_SHOPPING_CART_STATUS == 'True');

        $this->group = ((MODULE_BOXES_SHOPPING_CART_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 

'boxes_column_right');
      }
    }

    function execute() {
      global $cart, $new_products_id_in_cart, $currencies, $oscTemplate, $easy_discount;




      $cart_contents_string = '';

      if ($cart->count_contents() > 0) {
        $cart_contents_string = NULL;
        $products = $cart->get_products();
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {

          $cart_contents_string .= '<li';
          if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]

['id'])) {
            $cart_contents_string .= ' class="newItemInCart"';
          }
          $cart_contents_string .= '>';

          $cart_contents_string .= $products[$i]['quantity'] . ' x ';

          $cart_contents_string .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]

['id']) . '">';

          $cart_contents_string .= $products[$i]['name'];

          $cart_contents_string .= '</a></li>';

          if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]

['id'])) {
            tep_session_unregister('new_products_id_in_cart');
          }
        }

        $cart_contents_string .= '<li class="text-right"><br>' . $currencies->format($cart->show_total()) . '</li>';

if ($easy_discount->count() > 0) {
$cart_contents_string .= '<li class="text-right"><br>' . $currencies->format(easy_discount_total()) . '</li>';

$cart_contents_string .= '<li class="text-right"><br>' . $currencies->format($cart->show_total() - easy_discount_total

()) . '</li>';
}
      } else {
        $cart_contents_string .= '<p>' . MODULE_BOXES_SHOPPING_CART_BOX_CART_EMPTY . '</p>';
      }
              
      ob_start();

      include(DIR_WS_MODULES . 'boxes/templates/shopping_cart.php');
      $data = ob_get_clean();

      $oscTemplate->addBlock($data, $this->group);
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_BOXES_SHOPPING_CART_STATUS');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, 

configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values 

('Enable Shopping Cart Module', 'MODULE_BOXES_SHOPPING_CART_STATUS', 'True', 'Do you want to add the module to your 

shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, 

configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values 

('Content Placement', 'MODULE_BOXES_SHOPPING_CART_CONTENT_PLACEMENT', 'Right Column', 'Should the module be loaded in 

the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, 

configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 

'MODULE_BOXES_SHOPPING_CART_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this-

>keys()) . "')");
    }

    function keys() {
      return array('MODULE_BOXES_SHOPPING_CART_STATUS', 'MODULE_BOXES_SHOPPING_CART_CONTENT_PLACEMENT', 

'MODULE_BOXES_SHOPPING_CART_SORT_ORDER');
    }
  }
?>

I added $easy_discount into the global part at the top but well i don't really know if that is the way to go.

 

 

@@Jack_mcs thanks for pointing out this addon ( code) to me in the other thread it is fiddly but very flexible.

Edited by douglaswalker
Link to comment
Share on other sites

  • 3 years later...

anybody have this (or something similar) working in Phoenix?

Jim Bullen - President

The Cigar Hut Group of Companies

 

 

Installed add-ons: (that now need to be upgraded to OSC CE Phoenix)

PWA, MVS, Easy Populate, Dynamic Sitemap, Featured Products, MVS Order Editor, MVS Shipping Estimator, Google XML Sitemap, About Us, Ad Tracker, Address Enhancer, Also Purchased, Backorders, Category Descriptions, Dynamic Meta Tags, Contact Us Email Subjects, Country state Selector, Extra Address Line, Order Number in Email Subject, OSC Affiliate, Product Extra Fields, Review Approval System, Reviews in Product Display, Sold Out, Sold Out (but Displayed), Ultimate SEO URL's, Updated Spiders, Welcome Email Password, Pending Order Email, Who's Online Enhancement, CCGV, Easy Discounts, Customer Comments, Request a Review, Sales Report, plus many many more!

Link to comment
Share on other sites

8 minutes ago, cigarsforless said:

anybody have this (or something similar) working in Phoenix?

Hey Jim,

Check this one by @swguy https://apps.oscommerce.com/QdusL&quantity-discounts-for-osc-phoenix

This one works perfectly in my store (version 1.0.6.0). It's an excellent add on. No core code changes required.

There's also this one: https://apps.oscommerce.com/XpyA1&better-together-for-phoenix

I haven't used that one recently, but it was working fine in later versions of Phoenix.

Peter

 

CE PHOENIX SUPPORTER

Support the Project, go PRO and get access to certified add ons

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Link to comment
Share on other sites

Both Better Together and Quantity Discounts (as well as several of my commercial mods) *are* working in osCommerce Phoenix. 

Contributions: Better Together and Quantity Discounts for osCommerce 2.3.x and Phoenix. See my profile for more details.

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