Author Topic: Stock Administration - modify Price[solved]  (Read 2982 times)

Offline gearup

  • Posts: 82
Stock Administration - modify Price[solved]
« on: March 16, 2013, 12:14:35 AM »
Hi,

I have changed the code so I can modify the price on the Stock Administration page.

What I cannot seem to do is display the currency.

I have changed the stock.php code from,

Code: [Select]
line 138
<td width="115" align="center"><?php echo gmdate(DEFAULT_DATE_FORMAT$item['modified_when']+TIMEZONE); ?></td>
Line 140
<td width="30" align="right"><?php echo $item['price']; ?></td>

to

Code: [Select]
line 138
<td width="105" align="center"><?php echo gmdate(DEFAULT_DATE_FORMAT$item['modified_when']+TIMEZONE); ?></td>
Line 140
<td width="70" align="left"><input type="text" name="price[<?php echo $item['item_id']; ?>]" value="<?php echo $item['price']; ?>" style="width: 50px; text-align: right;" /></td>

This lets me modify the Price on the Stock Administration page ok but I also want to see the currency.

I also adjusted positioning so there is enough room for the currency to be displayed.

I cannot see how to fit in the currency display, I have code to insert but it does not seem to work,

Code: [Select]
&nbsp;<?php echo $fetch_settings['shop_currency']; ?>

Help please,
« Last Edit: March 16, 2013, 09:20:31 AM by gearup »
Tomorrow is a day we can look forward to but will never see.

jacobi22

  • Guest
Re: Stock Administration - modify Price
« Reply #1 on: March 16, 2013, 05:51:57 AM »
you have to read the settings first
put this code into the stock.php, in a free line before you read the bakery page list

Code: [Select]
$query_general_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_bakery_general_settings");
if ($query_general_settings->numRows() > 0) {
        $fetch_general_settings = $query_general_settings->fetchRow();
        $setting_shop_currency = stripslashes($fetch_general_settings['shop_currency']);
        }

i change the code for the line 140 (see your post)
Code: [Select]
<td width="100" align="left"><input type="text" name="price[<?php echo $item['item_id']; ?>]" value="<?php echo $item['price']; ?>" style="width: 50px; text-align: right;" /><?php echo $setting_shop_currency?></td>

Offline gearup

  • Posts: 82
Re: Stock Administration - modify Price
« Reply #2 on: March 16, 2013, 08:14:28 AM »
Thanks jacobi22,

The display of currency works now.

I should have guessed the reason it was not displaying before was because I didn't have the value.

I added in &nbsp; just so it displays better.

However, if anyone else want to make this change here is the final code to allow editing and currency display;

btw I am using bakery 1.59.

Add the following code above line 109 (comment line // Query items table)
Code: [Select]
// Query item currency
$query_general_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_bakery_general_settings");
if ($query_general_settings->numRows() > 0) {
        $fetch_general_settings = $query_general_settings->fetchRow();
        $setting_shop_currency = stripslashes($fetch_general_settings['shop_currency']);
}


and modify the original line 140 (for price) to
Code: [Select]
<td width="100" align="left"><input type="text" name="price[<?php echo $item['item_id']; ?>]" value="<?php echo $item['price']; ?>" style="width: 50px; text-align: right;" />&nbsp;<?php echo $setting_shop_currency?></td>


To save the edits of price back in the database you need to change save-stock.php

(I think my cut/paste change below is safe but if someone could please just confirm...)

Code: [Select]
// Loop through the items...
foreach ($_POST['stock'] as $item_id => $stock) {
$stock = $admin->add_slashes(strip_tags($stock));
$price = $admin->add_slashes(strip_tags($_POST['price'][$item_id]));
$active = isset($_POST['active'][$item_id]) ? 1 : 0;
// ...and update items
$database->query("UPDATE ".TABLE_PREFIX."mod_bakery_items SET stock = '$stock', price = '$price', active = '$active' WHERE item_id = '$item_id'");
}


regards,
« Last Edit: March 16, 2013, 11:19:45 AM by gearup »
Tomorrow is a day we can look forward to but will never see.

Offline seanie_morris

  • Posts: 287
  • Gender: Male
Re: Stock Administration - modify Price
« Reply #3 on: October 18, 2016, 01:15:00 PM »
btw I am using bakery 1.59.

Just adding that the above procedures worked for me just now in bakery 1.72.

Seanie.