Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Admin Category Products Sale Updater
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 05-14-2017, 11:02 AM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,391
 

Default Admin Category Products Sale Updater

Hello Everyone,

We are constantly putting items on sale and taking others off sale. I have wanted a more efficient way of handling this without having to do export/edit/import. I finally got around to making the necessary changes in a couple of files.

The attached image shows 3 new columns tacked on to the right. On the Admin Category Products page you can now edit the 'List Price(market price)' and if you have the "On Sale Module' you can turn the 'Sale' ribbon on and off too. If you have a value in both Price fields you will see the amount of discount. If 'Your Price' is greater than the 'List(market price)' it will show 'P>L ?'.

Click image for larger version

Name:	admin_cat_prod_sale_updater.jpg
Views:	34
Size:	58.5 KB
ID:	4918

I hope this is of use to some of you and feel free to edit/correct what I've done.

Thanks,

Paul



In: include/process_product.php

After:
Code:
// Include 'avail' field into the updating list if (isset($v['avail']) && is_numeric($v['avail'])) $update[] = "avail='".intval($v["avail"])."'";

Add:
Code:
if (isset($v['list_price']) && is_numeric($v['list_price'])) $update[] = "list_price='".strval($v["list_price"])."'"; if (isset($v['on_sale'])) $update[] = "on_sale='".($v["on_sale"])."'";


In file: skin/common_files/main/products.tpl

Before:
Code:
</tr> {section name=prod loop=$products} <tr{cycle values=', class="TableSubHead"'}>

add:
Code:
<td nowrap="nowrap">{$lng.lbl_list_price} ({$config.General.currency_symbol})</a></td> <td nowrap="nowrap">Discount</td> {if $active_modules.On_Sale} <td nowrap="nowrap">{$lng.lbl_on_sale}</a></td> {/if}


Before
Code:
</tr> {/section} </table> {/if}


Add:
Code:
<td align="center"> {if $products[prod].product_type ne 'C'} <input type="text" size="9" maxlength="15" name="posted_data[{$products[prod].productid}][list_price]" value="{$products[prod].list_price|formatprice}"{if $products[prod].is_variants eq 'Y'} readonly="readonly" onclick="javascript: pvAlert(this);"{/if} /> {/if} </td> <td align="center"> {if $products[prod].product_type ne 'C'} {if $products[prod].list_price gt 0 && $products[prod].price gt 0} {if $products[prod].list_price gt $products[prod].price} {math equation="100 - (ourPrice / listPrice * 100)" ourPrice=$products[prod].price listPrice=$products[prod].list_price format="%.2f"}% {elseif $products[prod].list_price == $products[prod].price} 0% {else} P>L ? {/if} {/if} {/if} </td> {if $active_modules.On_Sale} <td align="center"> {if $products[prod].product_type ne 'C'} <select name="posted_data[{$products[prod].productid}][on_sale]"> <option value="N" {if $products[prod].on_sale eq "N"} selected="selected"{/if}>{$lng.lbl_no}</option> <option value="Y" {if $products[prod].on_sale eq "Y"} selected="selected"{/if}>{$lng.lbl_yes}</option> </select> {/if} </td> {/if}
__________________
X-Cart Gold v4.6.6 PHP 5.6 (live)
X-Cart Gold v4.7.10 PHP 7.2 (in development)
  • XCARTMODS.CO.UK | reBOOT Template |
  • Smack Digital | CDSEO Pro 2.0 + Custom Replacements | Category SEO Map |
  • CODECANYON | Dynamic Website Compressor |
  • Total Server Solutions Hosting | Linux | PHP v 5.6.37 | MySQL v5.6.40 |
Reply With Quote

The following user thanks elmirage001 for this useful post:
PhilJ (05-14-2017)
  #2  
Old 05-14-2017, 07:19 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Location: UK
Posts: 3,519
 

Default Re: Admin Category Products Sale Updater

Nice one Paul, hope the house is coming along nicely...
__________________
xcartmods.co.uk


Reply With Quote

The following user thanks PhilJ for this useful post:
elmirage001 (05-15-2017)
  #3  
Old 05-15-2017, 06:41 AM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,391
 

Default Re: Admin Category Products Sale Updater

Hi Phil !

Thanks! I'll send you a pic of the house progress later today. Can't wait to hear about your new template!

Have a great day!

Paul
__________________
X-Cart Gold v4.6.6 PHP 5.6 (live)
X-Cart Gold v4.7.10 PHP 7.2 (in development)
  • XCARTMODS.CO.UK | reBOOT Template |
  • Smack Digital | CDSEO Pro 2.0 + Custom Replacements | Category SEO Map |
  • CODECANYON | Dynamic Website Compressor |
  • Total Server Solutions Hosting | Linux | PHP v 5.6.37 | MySQL v5.6.40 |
Reply With Quote
  #4  
Old 08-20-2017, 09:20 AM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,391
 

Default Re: Admin Category Products Sale Updater

I was using this yesterday morning and thought of a way to make it much easier and super quick. What if there was a pull down where I could select the discount and then click update and the price, list price, and On Sale Y/N selection would all be done for me. So I spent a few hours in the afternoon working on it.

Please feel free to post all edits/corrections. I've not fully tested if you don't have the "On Sale" Module. Test on your development store before using on your live store. Use at your own risk as I only know enough to be dangerous

The below attachment shows how it works.

Click image for larger version

Name:	admin_sale_updater_2.jpg
Views:	34
Size:	161.7 KB
ID:	5011

On the attachment you can see the new column added to set the discount amount. I had to add a field to the 'xcart_products' table called 'set_discount'.

Code:
ALTER TABLE `xcart_products` ADD `set_discount` INT NOT NULL DEFAULT '99';

I set the default amount to 99. A value of 99 is the manual mode and with all products having a 99 default value no changes are made to existing pricing. I only use the 'list price' when I have something on sale and it's zero the rest of the time. If you use 'list price' differently you'll have to edit the code.

The edited code sections are below and replace the original 3 edits from the above post.

Code:
if ($v['set_discount'] != '99') { if ($v['list_price'] > 0) { $v["on_sale"] = 'Y'; $v['price'] = $v['list_price'] * ((100- $v['set_discount'])/100); } else { $v["on_sale"] = 'N'; if ($v['set_discount'] > 0) { $v['list_price'] = $v['price']; $v['price'] = $v['list_price'] * ((100- $v['set_discount'])/100); $v["on_sale"] = 'Y'; } } if ($v['set_discount'] == 0) { $v["on_sale"] = 'N'; if ($v['list_price'] > 0) { $v['price'] = $v['list_price']; $v['list_price'] = 0; } } } if (isset($v['list_price']) && is_numeric($v['list_price'])) $update[] = "list_price='".strval($v["list_price"])."'"; if (isset($v['set_discount']) && is_numeric($v['set_discount'])) $update[] = "set_discount='".strval($v["set_discount"])."'"; if (isset($v['on_sale'])) $update[] = "on_sale='".($v["on_sale"])."'";



Code:
<td nowrap="nowrap">{$lng.lbl_list_price} ({$config.General.currency_symbol})</a></td> <td nowrap="nowrap">Discount %</td> <td nowrap="nowrap">Set Discount</td> {if $active_modules.On_Sale} <td nowrap="nowrap">{$lng.lbl_on_sale}</a></td> {/if}

Code:
<td align="center"> {if $products[prod].product_type ne 'C'} <input type="text" size="9" maxlength="15" name="posted_data[{$products[prod].productid}][list_price]" value="{$products[prod].list_price|formatprice}"{if $products[prod].is_variants eq 'Y'} readonly="readonly" onclick="javascript: pvAlert(this);"{/if} /> {/if} </td> <td align="center"> {if $products[prod].product_type ne 'C'} {if $products[prod].list_price gt 0 && $products[prod].price gt 0} {if $products[prod].list_price gt $products[prod].price} {math equation="100 - (ourPrice / listPrice * 100)" ourPrice=$products[prod].price listPrice=$products[prod].list_price format="%.2f"}% {elseif $products[prod].list_price == $products[prod].price} 0% {else} P>L ? {/if} {/if} {/if} </td> <td align="center"> {if $products[prod].product_type ne 'C'} <select name="posted_data[{$products[prod].productid}][set_discount]"> <option value="0" {if $products[prod].set_discount eq 0} selected="selected"{/if}>0</option> <option value="10" {if $products[prod].set_discount eq 10} selected="selected"{/if}>10</option> <option value="15" {if $products[prod].set_discount eq 15} selected="selected"{/if}>15</option> <option value="20" {if $products[prod].set_discount eq 20} selected="selected"{/if}>20</option> <option value="99" {if $products[prod].set_discount eq 99} selected="selected"{/if}>99</option> </select> {/if} </td> {if $active_modules.On_Sale} <td align="center"> {if $products[prod].product_type ne 'C'} <select name="posted_data[{$products[prod].productid}][on_sale]"> <option value="N" {if $products[prod].on_sale eq "N"} selected="selected"{/if}>{$lng.lbl_no}</option> <option value="Y" {if $products[prod].on_sale eq "Y"} selected="selected"{/if}>{$lng.lbl_yes}</option> </select> {/if} </td> {/if}
__________________
X-Cart Gold v4.6.6 PHP 5.6 (live)
X-Cart Gold v4.7.10 PHP 7.2 (in development)
  • XCARTMODS.CO.UK | reBOOT Template |
  • Smack Digital | CDSEO Pro 2.0 + Custom Replacements | Category SEO Map |
  • CODECANYON | Dynamic Website Compressor |
  • Total Server Solutions Hosting | Linux | PHP v 5.6.37 | MySQL v5.6.40 |
Reply With Quote

The following user thanks elmirage001 for this useful post:
PhilJ (08-20-2017)
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:46 PM.

   

 
X-Cart forums © 2001-2018