[solved]Produced From not saved

A shopping addon for Roster

Moderator: Hannah

[solved]Produced From not saved

Postby Rihlsul » Sat Jul 15, 2006 2:31 am

I could be doing something wrong, but I go to my fresh new install of 1.70 and into the shopping system.

I click on a few different items to add them to the cart.

I then change all the Produced By values to a particular person.

When the data is coming down via UniLoader, I see that the Produced By has come back to the first person in the list:

Code: Select all
shoppinglist = {
   [1] = {
      [1] = "Esmerelda",
      [2] = "1",
      [3] = "Small Silk Pack",
      [4] = "Qrunch",
      [5] = "1",
      [6] = "outbox",
      [7] = "0",
      [8] = "",
   },
   [2] = {
      [1] = "Kodian",
      [2] = "1",
      [3] = "Black Silk Pack",
      [4] = "Qrunch",
      [5] = "2",
      [6] = "outbox",
      [7] = "0",
      [8] = "",
   },
   [3] = {
      [1] = "Albel",
      [2] = "1",
      [3] = "Woolen Bag",
      [4] = "Qrunch",
      [5] = "3",
      [6] = "outbox",
      [7] = "0",
      [8] = "",
   },
   [4] = {
      [1] = "Damnmage",
      [2] = "1",
      [3] = "Enchant Bracer - Minor Strength",
      [4] = "Qrunch",
      [5] = "4",
      [6] = "outbox",
      [7] = "0",
      [8] = "",
   },
}


In every case, the [1] is the first person in the Produced By list. Shouldn't that change to reflect who I've ordered it to be Produced By?

Specs: Roster 1.70
Shopping: 04
MySQL: 5.0.18
PHP: 5.1.2
Last edited by Rihlsul on Wed Aug 16, 2006 12:28 pm, edited 2 times in total.
Rihlsul,
Guild Leader of The Dirty Hordes
User avatar
Rihlsul
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 125
Joined: Tue Jul 04, 2006 8:27 pm

Re: Produced From not saved

Postby Rihlsul » Sat Jul 15, 2006 3:18 am

I'm a LUA n0.0b, but am I reading this function right?

This is from functions_cart.php:
Code: Select all
   function insertOrder(){
       db_connect();
       global $table_prefix;
       $i=0;
       $size = count($_SESSION["cart"]);
       for($i=0; $i <= $size-1; $i++){
   
      //check if maker is more than two members (workaround needs to be changed for future)
      $string = explode(",",$_SESSION["cart"][$i][2]);
      $num = count($string);
      
      if($num > 1){
          $_SESSION["cart"][$i][2] = $string[0];
      }
      
      mysql_query("INSERT INTO `".$table_prefix."addon_shopping` (`order_number`, `order_item`, `order_quantity`,
          `order_maker`, `order_requester`, `order_maxprice`, `order_note`,
          `order_price_demand`, `order_date`, `order_state`, `order_info`)
          VALUES ('','".$_SESSION["cart"][$i][0]."','".$_SESSION["cart"][$i][1]."','".$_SESSION["cart"][$i][2]."','".$_SESSION["sendto"]."',
          '0', '', '', NOW(), 'outbox', '');");
         
          }
   }


So, .$_SESSION["cart"][$i][2]. is put into order_maker.

When I look at the VIEW_CART HTML source, I see that Product By is named "maker_wahl0", "maker_wahl1" etc.

Yet, in phpCart_manage.php, there is:

$_SESSION["cart"][$i][3] = $_POST["maker_wahl".$i];

Produced By is going into [$i][3].

And further down in phpCart_manage.php, when you're updating the LUA file,
Code: Select all
    $content .= "shoppinglist = {\n";
    for ($i = 0; $i <= $size-1; $i++) {
   $content .= "\t{ \"".$_SESSION["cart"][$i][3]."\",
".$_SESSION["cart"][$i][1].", \"".$_SESSION["cart"][$i][0]."\",
\"".$_SESSION["sendto"]."\",},\n";
              }
    $content .= "}";


So, it seems like Produced By is always in [$i][3].

Shouldn't functions_cart.php reference [$i][3]?

I'll be trying that, since I'm just experimenting with it for now anyways.
Last edited by Rihlsul on Sat Jul 15, 2006 3:18 am, edited 1 time in total.
Rihlsul,
Guild Leader of The Dirty Hordes
User avatar
Rihlsul
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 125
Joined: Tue Jul 04, 2006 8:27 pm

Re: Produced From not saved

Postby Rihlsul » Sat Jul 15, 2006 3:38 am

Confirmed. I changed my function to use [$i][3] and it stored things to the database and LUA file just fine.

Hope my sad attempts at fixing things is helpful.

Updated function_cast.php function insertOrder()
Code: Select all
   function insertOrder(){
       db_connect();
       global $table_prefix;
       $i=0;
       $size = count($_SESSION["cart"]);
       for($i=0; $i <= $size-1; $i++){
   
      //check if maker is more than two members (workaround needs to be changed for future)
      $string = explode(",",$_SESSION["cart"][$i][3]);
      $num = count($string);
      
      if($num > 1){
          $_SESSION["cart"][$i][3] = $string[0];
      }
      
      mysql_query("INSERT INTO `".$table_prefix."addon_shopping` (`order_number`, `order_item`, `order_quantity`,
          `order_maker`, `order_requester`, `order_maxprice`, `order_note`,
          `order_price_demand`, `order_date`, `order_state`, `order_info`)
          VALUES ('','".$_SESSION["cart"][$i][0]."','".$_SESSION["cart"][$i][1]."','".$_SESSION["cart"][$i][3]."','".$_SESSION["sendto"]."',
          '0', '', '', NOW(), 'outbox', '');");
         
          }
   }   


Same file, function changeNumbertoMember()
Code: Select all
   function changeNumbertoMember()
         {
         $i = 0;
         $size = count($_SESSION["cart"]);
         for ($i = 0; $i <= $size-1; $i++) {
            if(is_numeric($_SESSION["cart"][$i][3])){
               $membername = explode(",",$_SESSION["cart"][$i][3]);
               $_SESSION["cart"][$i][3] = $membername[($_SESSION["cart"][$i][3])];
               }
            }         
         }
Rihlsul,
Guild Leader of The Dirty Hordes
User avatar
Rihlsul
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 125
Joined: Tue Jul 04, 2006 8:27 pm

Re: Produced From not saved

Postby Hannah » Sat Jul 15, 2006 12:15 pm

Hi!

Good work :)

Had the same error in my firste version, somehow i put it back again :(

I´ll change it in the code...

Great work Rihlsul

CU

Hannah
User avatar
Hannah
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 142
Joined: Tue Jul 04, 2006 1:41 pm
Location: Germany, Cologne


Return to Shopping

Who is online

Users browsing this forum: No registered users and 1 guest

cron