Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

I want to implement an unusual system of discounts

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 11-26-2014, 01:15 AM
  dagdag's Avatar 
dagdag dagdag is offline
 

Advanced Member
  
Join Date: Sep 2014
Location: Volgograd
Posts: 81
 

Question I want to implement an unusual system of discounts

I need to implement the code, which, depending on the amount of goods of a certain category of repeat purchases and calculates the new price for this product. Dependence is very nonlinear, an example - in the picture in attachment.

I was looking for documentation http://kb.x-cart.com/display/XDD/Definitive+guide and read the forum but could not find any documentation or sample code

Please show me examples or documentation, how to work with a basket of goods and prices in X-CART 5. I really want to understand programming X-CART 5.

Thanks in advance!
Attached Thumbnails
Click image for larger version

Name:	price.jpg
Views:	328
Size:	162.7 KB
ID:	4005  
__________________
my wife's shop
Reply With Quote
  #2  
Old 11-26-2014, 06:41 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: I want to implement an unusual system of discounts

Thanks for the question.

Simply put, we need a mod that will work as follows:

first purchase of the customer
- buy 3 products -- one will be free
- buy 6 products -- two will be free

next purchase of the same customer will trigger 10% discount and the bonus products will remain the same:
- buy 3 products -- one will be free
- buy 6 products -- two will be free

Do I understand you properly?

Should this special offer work for all products in the store or for ones from specific category only?

I am planning to create a video tutorial about creating such special-offer-like mods and this mod is a great example, so I probably take this idea and will make a video guide based on it.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote

The following user thanks tony_sologubov for this useful post:
Ksenia (11-26-2014)
  #3  
Old 11-26-2014, 09:59 PM
  dagdag's Avatar 
dagdag dagdag is offline
 

Advanced Member
  
Join Date: Sep 2014
Location: Volgograd
Posts: 81
 

Default Re: I want to implement an unusual system of discounts

Thank you, Tony!

I perfectly understand you, especially because the programmer.
This special offer work for ones from specific category only.

Quote:
create a video tutorial about creating such special-offer-like mods and this mod is a great example, so I probably take this idea and will make a video guide based on it.
This is a great idea! I'll wait for your video tutorial.

Thank you so much, God is with you!
Reply With Quote
  #4  
Old 11-28-2014, 03:56 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: I want to implement an unusual system of discounts

Thank you so much for your understanding!
This video will be ready in 1~2 weeks. I will update a thread, once I am done.

Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #5  
Old 12-10-2014, 07:00 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: I want to implement an unusual system of discounts

Hi!

I realized that this module is too complex to be a tutorial example, but I have just written a simple implementation of what you need and the pack is here:
https://dl.dropboxusercontent.com/u/23858825/Tony-SpecialOfferForDag-v5_1_0.tar
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #6  
Old 12-11-2014, 01:16 AM
  dagdag's Avatar 
dagdag dagdag is offline
 

Advanced Member
  
Join Date: Sep 2014
Location: Volgograd
Posts: 81
 

Default Re: I want to implement an unusual system of discounts

Thanks, Tony!
I will download and learn...

---

upd:
I wrote a module based on your example, it works !!! Thanks!!!
Such a way to provide much better information than video lessons...
idea: collect all your advice in one wiki (or msdn style) library...
Reply With Quote
  #7  
Old 12-14-2014, 10:56 PM
  dagdag's Avatar 
dagdag dagdag is offline
 

Advanced Member
  
Join Date: Sep 2014
Location: Volgograd
Posts: 81
 

Default Re: I want to implement an unusual system of discounts

Only one update:

To avoid fraud buyer discount - need to calculate the real status of previous orders:
PHP Code:
protected function hasDiscount()
    {
        
$discountState false

        
$profile = \XLite\Core\Auth::getInstance()->getProfile();
        if (
$profile) {
            
$cnd = new \XLite\Core\CommonCell();
            
$cnd->profile $profile;
            foreach (\
XLite\Core\Database::getRepo('XLite\Model\Order')->search($cnd) as $order) {
                
$orderState $order->getPaymentStatusCode();
                 if (
$orderState == \XLite\Model\Order\Status\Payment::STATUS_REFUNDED)
            { 
$discountState false; break; }
                if (
$orderState == \XLite\Model\Order\Status\Payment::STATUS_PAID)
            
$discountState true;
            }
        }

        return 
$discountState;
    } 
Reply With Quote

The following user thanks dagdag for this useful post:
tony_sologubov (12-15-2014)
  #8  
Old 12-15-2014, 02:44 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: I want to implement an unusual system of discounts

Quote:
Originally Posted by dagdag
I wrote a module based on your example, it works !!! Thanks!!!
Such a way to provide much better information than video lessons...
idea: collect all your advice in one wiki (or msdn style) library...

Thanks for the advice! This is exactly what I am doing right now. I hope to finish all basic examples by the end of this month and they will be available here:
http://kb.x-cart.com/display/XDD/Developer+docs
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:39 AM.

   

 
X-Cart forums © 2001-2020