X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Admin Category Products Sale Updater (https://forum.x-cart.com/showthread.php?t=75341)

elmirage001 05-14-2017 11:02 AM

Admin Category Products Sale Updater
 
1 Attachment(s)
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 ?'.

Attachment 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}


PhilJ 05-14-2017 07:19 PM

Re: Admin Category Products Sale Updater
 
Nice one Paul, hope the house is coming along nicely... :)

elmirage001 05-15-2017 06:41 AM

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

elmirage001 08-20-2017 09:20 AM

Re: Admin Category Products Sale Updater
 
1 Attachment(s)
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 :smile:

Edited: This only works for items < $1000 !!!



The below attachment shows how it works.

Attachment 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} 



All times are GMT -8. The time now is 06:51 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.