Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-23-2014, 04:45 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,275
Kyttias is on a distinguished road
Default Shop Discount

Nvm, got it work finally. -o-

If you send another value, for a discount, through the buy form, you can access it in class_stockitem.php in the getcost function. But this is just to fix the display on the confirmation screen.

PHP Code:
 public function getcost($salestax 0$quantity ""){
      
// Get the total cost of this stock item
      
$mysidia Registry::get("mysidia");
      if(empty(
$quantity)) $quantity $mysidia->input->post("quantity");
      
$discount $mysidia->input->post("discount");
      
$costbeforediscount $this->price*$quantity*(1+$salestax/100);
    
$cost $costbeforediscount * ((100-$discount) / 100);
      return 
$cost;
  } 
To show users a discounted price, you'll need to do this in the display function of class_itemshop.php -
PHP Code:
# A 5% discount:
$discount 5;
$price $item->price * ((100-$discount) / 100); 
And replace the $item->price where it would show the item's price when rendering the item to just $price.

To actually make a discount percentage go through in terms of calculations you'll have to modify the purchase() function in class_itemshop.php -

PHP Code:
$cost $item->getcost($this->salestax$item->quantity) * ((100-$discount) / 100); 
Sorry for the vague ramblings, it's actually the first part I had trouble with (getting the proper amount to show on the confirmation screen), but maybe someone will have gotten something out of rest of this.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 12-23-2014 at 05:46 PM.
Reply With Quote
  #2  
Old 12-23-2014, 05:19 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 20,857
IntoRain is on a distinguished road
Default

I can't really test this, since my host is yet again down for maintenance, but did you try (purchase() in shopview.php):

PHP Code:
$shop_id $mysidia->input->get("shop");

//i'm not sure if input->get("shop") is the name or the sid. If it's the name, but you want the sid:

$shop = new Itemshop($mysidia->input->get("shop"));
$shop_id $shop->sid
In theory, you can access $mysidia->input->get("shop") from both sides (controller and view) since it's a variable sent by GET.

If you want to send a value from the controller to the view:

PHP Code:
//controller
$this->setField("discount", new Integer($discount));
//view
$discount $this->getField("discount")->getValue(); 
The getField is to retrieve the field from the hashmap (it's what's used to communicate variables between controller and view). The getValue is to get the internal value from the object (in this case the object is Integer and the value is an int)
__________________


asp.net stole my soul.

Last edited by IntoRain; 12-23-2014 at 05:32 PM.
Reply With Quote
  #3  
Old 12-23-2014, 05:48 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,275
Kyttias is on a distinguished road
Default

Thanks, but I did some further squinting and I got the desired result in the end (editted the first post).
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #4  
Old 12-23-2014, 05:51 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 20,857
IntoRain is on a distinguished road
Default

Alright, glad you figured it out
__________________


asp.net stole my soul.
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shop error? pachoofoosh Questions and Supports 1 10-30-2014 01:10 PM
Shop to buy an adoptable? SilverDragonTears Questions and Supports 8 08-16-2011 02:17 PM
System Shop sensacion Questions and Supports 0 05-08-2011 06:40 PM
Shop and... 12345 Questions and Supports 1 03-05-2009 07:59 AM
Shop? trollis76 Questions and Supports 6 02-20-2009 12:46 AM


All times are GMT -5. The time now is 04:19 PM.

Currently Active Users: 1097 (0 members and 1097 guests)
Threads: 4,081, Posts: 32,029, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636