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,
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
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,
<?php echo $fetch_settings['shop_currency']; ?>
Help please,
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
$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)
<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>
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 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)
// 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
<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>
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...)
// 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,
Quote from: gearup on March 16, 2013, 08:14:28 AM
btw I am using bakery 1.59.
Just adding that the above procedures worked for me just now in bakery 1.72.
Seanie.