WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Stock Administration - modify Price[solved]
  • Print
Pages: [1]   Go Down

Author Topic: Stock Administration - modify Price[solved]  (Read 8947 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 »
Logged
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>
Logged

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 »
Logged
Tomorrow is a day we can look forward to but will never see.

Offline seanie_morris

  • Posts: 301
  • Gender: Male
Re: Stock Administration - modify Price
« Reply #3 on: October 18, 2016, 01:15:00 PM »
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.
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Stock Administration - modify Price[solved]
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2