SMFShop > Coding
Several Modification Ideas
Steev:
I've made a project for the Variable Restock Rates, and will probably be making another one shortly for the Resellable items...but I have one question, since these are my first SMF mods...
Is there an easy way to make the .xml files for the install, or do I have to do the diffs and copy-paste everything manually?
JRSofty:
I personally think the copy/paste method works well. I tried using a package making software and was not happy with it at all. It wouldn't open an old package that it had already created, among other things.
Currently I do everything in my programming Text editor and I'm happy with that.
Daniel15:
--- Quote ---Is there an easy way to make the .xml files for the install, or do I have to do the diffs and copy-paste everything manually?
--- End quote ---
You need to copy-and-paste everything manually. It's not too hard, and good GUI diff tools (like WinMerge for Windows, or Meld for Linux) help quite a bit.
Like JRSofty, I do almost everything in my text editor (gedit on Linux, and Notepad++ on Windows). Most of the time, I don't need a diff tool, as I mark all my changes (eg. with // Begin SMFShop code and // End SMFShop code) so I can just search the file for "SMFShop" :)
Steev:
Fair enough. I've been marking my changes too (6 years in software development almost force you to), but the diff in EditPadPro gives me a quick glance at the changes to make it even easier. :)
Thanks for the help, guys.
Steev:
New question, same topic, and again, a thanks in advance for the help.
In ShopAdmin.template.php, I have the following:
--- Code: ---<table>
<tr>
<td align="right"><label for="itemname">', $txt['shop_name'], ':</label></td>
<td><input name="itemname" id="itemname" type="text" value="', $context['shop_edit']['name'], '" size="80" style="width: 100%" /></td>
</tr><tr>
<td align="right" valign="top"><label for="itemdesc">', $txt['shop_description'], ':</label></td>
<td><textarea name="itemdesc" id="itemdesc" cols="40" rows="6" style="width: 100%">', $context['shop_edit']['desc'], '</textarea></td>
</tr><tr>
<td align="right"><label for="itemprice">', $txt['shop_price'], ':</label></td>
<td>', $modSettings['shopCurrencyPrefix'], '<input name="itemprice" id="itemprice" type="text" value="', $context['shop_edit']['price'], '" size="5" />', $modSettings['shopCurrencySuffix'], '</td>
</tr><tr>
<td align="right"><label for="itemstock">', $txt['shop_stock'], ':</label></td>
<td><input name="itemstock" id="itemstock" type="text" value="', $context['shop_edit']['stock'], '" size="5" /></td>
</tr>';
//BEGIN CODE ADDED FOR Variable Restock Rates
echo '<tr>
<td align="right"><label for="stock_period">', $txt['shop_stock_period'], ':</label></td>
<td><input name="stock_period" id="stock_period" type="text" value="', $context['shop_item']['stock_period'], '"size="5" /></td>
</tr><tr>
<td align="right"><label for="stock_add">', $txt['shop_stock_add'], ':</label></td>
<td><input name="stock_add" id="stock_add" type="text" value="', $context['shop_item']['stock_add'], '"size="5" /></td>
</tr><tr>
<td align="right"><label for="max_stock">', $txt['shop_max_stock'], ':</label></td>
<td><input name="max_stock" id="max_stock" type="text" value="', $context['shop_item']['max_stock'], '"size="5" /></td>
</tr>';
//END CODE ADDED FOR Variable Restock Rates
echo '<tr>
<td align="right"><label for="cat">', $txt['shop_category'], ':</label></td>
<td>
--- End code ---
The form continues, but that gets all of my stuff in there.
In ShopAdmin.php, I have the following:\
--- Code: ---// Update the item information
// QUERY UPDATED FOR Variable Restock Rates
db_query("
UPDATE {$db_prefix}shop_items
SET name = '{$_POST['itemname']}',
`desc` = '{$_POST['itemdesc']}',
price = {$_POST['itemprice']},
stock = {$_POST['itemstock']},
image = '{$_POST['icon']}',
delete_after_use = {$delete},
category = {$_POST['cat']},
stock_period = {$_POST['stock_period']},
stock_add = {$_POST['stock_add']},
max_stock = {$_POST['max_stock']},
{$additional}
WHERE id = {$_POST['id']}
LIMIT 1", __FILE__, __LINE__);
--- End code ---
When I run it, it lets me get to the edit page, but the three new text fields are empty. And when I click Edit, I get a MYSQL error at the end of that ShopAdmin.php block.
I know I have some $context stuff in the template; did I miss a location where I need to add this data? I'm assuming that it's the $context being missing that's causing data to not make it over to the query, which is causing the query to fail. Can anyone help?
Edit: Removed extra tabs.
EditX2: Fixed the issue. It was two problems rolled into one. I was using $context['shop_item'] instead of ['shop_edit'] in the template, and I had an extra comma in the query, since $additional begins with a comma if it's needed.
I've now got this installed on my site, and things are working swimmingly at the moment. Thanks again.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version