Jump to content
Latest News: (loading..)

Recommended Posts

The error probably is that I'm missing that functions at classes/currencies.php. But does this version fix the issue about shipping costs?

Share this post


Link to post
Share on other sites
Posted (edited)
3 minutes ago, sinopia said:

The error probably is that I'm missing that functions at classes/currencies.php. But does this version fix the issue about shipping costs?

Yes, please update your currency class to the latest version of the current 2.3.4.1 BS EDGE. This function has been added there some time ago.

order subtotal and shipping discount is both supported in the last versions as separate options.

Current version is Discount Codes 4.3. BS

Edited by raiwa

Share this post


Link to post
Share on other sites

Hello @raiwa should I use this one -> https://raw.githubusercontent.com/BrockleyJohn/Responsive-osCommerce/master/includes/classes/currencies.php ?

Should I just add those functions into mine class? Here are mine:

<?php
/*
  $Id$

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

  Copyright (c) 2008 osCommerce

  Released under the GNU General Public License
*/

////
// Class to handle currencies
// TABLES: currencies
  class currencies {
    var $currencies;

// class constructor
    function __construct() {
      $this->currencies = array();
      $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
      while ($currencies = tep_db_fetch_array($currencies_query)) {
        $this->currencies[$currencies['code']] = array('title' => $currencies['title'],
                                                       'symbol_left' => $currencies['symbol_left'],
                                                       'symbol_right' => $currencies['symbol_right'],
                                                       'decimal_point' => $currencies['decimal_point'],
                                                       'thousands_point' => $currencies['thousands_point'],
                                                      'decimal_places' => (int)$currencies['decimal_places'],
                                                       'value' => $currencies['value']);
      }
    }

// class methods
    function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
      global $currency;

      if (empty($currency_type)) $currency_type = $currency;

      if ($calculate_currency_value == true) {
        $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
        $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
      } else {
        $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
      }

      return $format_string;
    }

    function calculate_price($products_price, $products_tax, $quantity = 1) {
      global $currency;

      return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;
    }

    function is_set($code) {
      if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) {
        return true;
      } else {
        return false;
      }
    }

    function get_symbol() {
        global $currency;

          $currency_type = $currency;

          if (trim($this->currencies[$currency_type]['symbol_left'])!='') {
              return $this->currencies[$currency_type]['symbol_left'];
          } else return $this->currencies[$currency_type]['symbol_right'];
        }
    function get_value($code) {
      return $this->currencies[$code]['value'];
    }

    function get_decimal_places($code) {
      return $this->currencies[$code]['decimal_places'];
    }

    function display_price($products_price, $products_tax, $quantity = 1) {
      return $this->format($this->calculate_price($products_price, $products_tax, $quantity));
    }
		
    function display_sale_percent($products_price, $products_tax, $special_price) {	
			if ($this->calculate_price($special_price, $products_tax, 1) != 100)	{
				if ($products_price != 0)	{
     			$sale_percent = 100 - $this->calculate_price($special_price, $products_tax, 1)/$products_price*100;
				}
			}
	  return tep_round($sale_percent, 1);
		
    }		
    function format_short($number) {
        if ($calculate_currency_value) {
          $rate = ($currency_value) ? $currency_value : $this->currencies[$currency_type]['value'];
          $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number * $rate, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  // if the selected currency is in the european euro-conversion and the default currency is euro,
  // the currency will displayed in the national currency and euro currency
          if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) {
            $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>';
          }
        } else {
          $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
        }

        $format_string = number_format($number, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']);
        $format_string = str_replace(',','',$format_string);

        return $format_string;
      }
  }
	echo $special_price;
?>

 

Share this post


Link to post
Share on other sites

Also some classes/function are using old PHP code.. For example:

        reset($this->modules);
        while (list(, $value) = each($this->modules)) {

which should become the following:

foreach($this->modules as $value) {

Can this cause some kind of errors?

Share this post


Link to post
Share on other sites
10 minutes ago, sinopia said:

Also some classes/function are using old PHP code.. For example:


        reset($this->modules);
        while (list(, $value) = each($this->modules)) {

which should become the following:


foreach($this->modules as $value) {

Can this cause some kind of errors?

 these are updates for php7.2 compatibility. For lower versions they are no required.

Share this post


Link to post
Share on other sites
Posted (edited)

Struggling with Paypal and this add on.  I had this working with earlier Paypal versions but since a recent Paypal update I must have lost a change along the way...

The discount itself works when paying with paypal, but I cannot get the customers_to_discount_codes to update.  If I have the code in the paypal_standard file to do this I get an SQL error that there is no value for discount code, so the discount code id is being dropped somwhere along the way.  

1366 - Incorrect integer value: '' for column 'discount_codes_id' at row 1

insert into customers_to_discount_codes (customers_id, discount_codes_id) values ('116812', '')

I quickly parsed through the thread to see if I could find anyone else with this issue but didn't come up with much.

 

C

Edited by cdetdi

Share this post


Link to post
Share on other sites

Hello @raiwa

I'm busy working to update my entire site to PHP7.2

On my live shop everything works well (not PHP7)  but on my xampp testing server PHP7 the discount code displays twice

I have only one instance of this code checkout_payment.php file, I have uninstalled/reinstalled the module, cleared database cache and browser cache :

  <hr>

  <div class="contentText">
    <div class="form-group">

Also; when entering a valid discount coupon code I get the red circle - not valid icon but the coupon is showing discount at checkout_confirmation.php

Let me know if there is anything to check on

code.jpg


Thanks to all source contributors, 2.3.4 Edge just works fine

https://github.com/gburton/Responsive-osCommerce/archive/master.zip

Share this post


Link to post
Share on other sites

Hello Pierre @Peper,

I just checked on a new 2.3.4.1 CE Frozen installation under PHP 7.2 and all works as it should.

- Please check in your database if you have the header tag module correct installed. Check if you have no duplicated entries.

- Search in your database in configuration table for " MODULE_HEADER_TAGS_INSTALLED " and check if you have the discount header tag duplicated in the list.

- Try to uninstall the header tag module and reinstall.

 

rgds

Rainer

Share this post


Link to post
Share on other sites

I've just installed the Discount code BS  on my new-ish BS site ( v2.3.4.1 CE ). 

I did use the previous version Discount code add on my previous non BS site.

A couple of questions -

 

1) I used to be able to configure whether to display the order subtotal either way - including the discount, or before the discount is applied.

I did this just by changing the sort order under Order Total by putting Discount code before Sub-Total.    Then the sub-total told the customer the amount including the discount.

So yes I can change the sort order still (under Order Total) but the sub-total will not now display the price including discount.   Is there anyway I can get this functionality back? 

 

2)  Exclude specials tick box area is greyed out when set on applies to Order-sub total.  Was there a reason for this? 

 

Not sure if I've missed anything so any help would be gratefully received!  

 

Share this post


Link to post
Share on other sites

Hello Ros, @Rosyweb,

1. I need a deeper look, but I believe this has been deprecated in favor to flexible sort order with shipping discounts and accurate tax calculation. It wouldn't be easy to recover it. Maybe it's easier to use a modified subtotal module.

2. Yes, the ot_discount.php module should support exclude specials for subtotal discounts. I guess the disabled numbering has been messed up somewhere in an update.

Please try the following modification in admin/discount_codes.php:

change line 192 to:

  for (var i = 0, n = a.length; i < n; i++) if (a[i].checked) { b.disabled = (a[i].value == 2 || a[i].value == 4 ? false : true); c.disabled = (a[i].value == 3 || a[i].value == 5 || a[i].value == 6 ? true : false); d.disabled = (a[i].value == 3 || a[i].value == 6 ? true : false) }

Let us know if it works correct on a test order and I'll upload the update.

Kind regards

Rainer

Edited by raiwa

Share this post


Link to post
Share on other sites

Raiwa, so with the change to line 192 you sent - it now lets me tick the Exclude Specials box (which using Applies to order Sub Total)  but it does not exclude the product that is a reduced item at the customers checkout. 

So hasn't worked properly. 

Share this post


Link to post
Share on other sites

Just tried different option and actually it doesn't exclude discounted items (specials) when any Applies to option is selected.  I've changed it back to the original code and the same. 

So something is going wrong if it is not excluding Specials.    Where can I check the code for this?  

 

Share this post


Link to post
Share on other sites

Hi Raiwa.  I'm sorry to say I've found some more things not working quite as they should.   I've included a screen shot.   

So firstly one of those items in the basket is a special, so shouldn't be included anyway.   
But the totaling is wrong.  It should all total to £151.46 not £152.57. 

 

So something isn't quite working right. ??

 

DiscountC_screen.jpg

Share this post


Link to post
Share on other sites

Thanks Raiwa

In: includes/modules/order_totals/ot_discount.php

So the code in this is straight out of the box and I have of course uploaded it.  So nothing I've done or not done to disrupt this. 

Share this post


Link to post
Share on other sites

Yes, it seems the support to exclude discounted products has been disabled because it doesn't work correct. I wasn't aware of this.

I will have a deeper look and try to fix it when I find some time. But I'm afraid this will not be soon.

Share this post


Link to post
Share on other sites

Thanks Raiwa,  I'm trying to get the old module working in BS, as that did work correctly. 

I'm part way there,  but need to iron out some other things.  I'll watch this space also for when you're able to look at the new BS version. 

The adding up in the BS version is a problem (obviously has to be accurate) , and really it does need to show a sub-total 'after' the discount applied. 

At present it looks like tax is added on after everything else although its already been accounted for (see my image above), so for the sub-total to show the amount after tax and after discount applied will be much clearer to the customer.   As it did in the older version.   Yes I think it may take a while to iron out problems with this one but thank you for looking at it. 

Share this post


Link to post
Share on other sites

@raiwa

As far I know the "exclude specials" feature only worked when you check any other checkbox (products, categories, manufacturers, customers) except for order total. If you apply a discount on order total it does not check what products are inside it only takes the sub-total value.

I just did a quick test and it does work just fine with let's say checked Products and select all products inside it.
I am not sure however if the exclude specials feature ever worked with order total in the version that we based this BS on. That would need further investigation but I highly doubt it ever did.

 

Share this post


Link to post
Share on other sites

@Tsimi,

Yes, you are right. I had a look in the old, pre-BS version and the exclude specials was always limited to products/categories/manufacturers discount. It never was possible to apply it to order subtotal discounts.

The sort order also needed always to be set to:

1. subtotal

2. discount

......

 

@Rosyweb, it seems you were using another dicount code add-on, not the one on which Discount Code BS is based on. If you need these features, then you have to stick for now with the old one you were using.

Both features are useful, but we'll see if me or Lambros find time to implement them.

Edited by raiwa

Share this post


Link to post
Share on other sites

Hello Tsimi. 

So now I'm getting confused.   

Under Catalog / Discount codes -  Yes I can tick the box for 'excludes specials' when set on Applies to:  Products or Categories or Manufacturers,    and it will let me click the Save button, but on any of these 'Applies to' it will NOT create the discount code.  I click on save and it does nothing.  BUT when I select Applies to ' Order Sub-Total '  - it greys out the exclude specials option and when I click on the Save button this time it takes me back to the discount code list showing that a discount code has been created.  My new discount code is now added to the list. 

It also works on Applies to 'Shipping'.   

But when any other Applies to are selected - then the code will not be created upon clicking on the save button.


Is this the behaviour that you are expecting?   

1) Are you, when on your site - able to choose select Products and then choose' exclude Specials' and click save and it actually creates that code successfully and adds it to you list?    

2) Then does that code follow through and work and actually exclude the specials when you try it out in cart view? 

many thanks

Share this post


Link to post
Share on other sites

@Rosyweb

Hi Ros

1) Yes

2) Yes

When you tick for example the check box for Products you will have to choose one or multiple or even all products from the list below that checkbox (small inframe)
To select multiple products on a Windows PC just keep holding the CTRL button and click the products that you want to allow to apply that coupon code.
To simply select all products just click the very first product and then scroll all the way down and hold the SHIFT button and click the last product on the list now all products within the list should be selected. Then click the save button.
If you don't select any product it won't do anything when you click the save button. Same goes for Categories or Manufacturers or Customers.

Edited by Tsimi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×