Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Mod to add cost field Rate Topic   - - - - -

 
  • brandonvd
  • is Super Awesome
  • Members
  • Join Date: 19-Dec 06
  • 2633 posts

Posted 29 January 2011 - 05:43 AM #1

This mod will add a cost field to your admin. It will put the field in both your product list page and you product details page.

To start out, some credit goes to Snorocket. He has some of this over at his forum at http://www.snorocket...ct-details-page.

Ok, to start:

1.) In phpMyAdmin do:

ALTER TABLE `cscart_products` ADD `cost` DECIMAL (10,2) AFTER `product_code` ;

2.) Add your language variables

Language variable: cost
Value: Cost

3.) In core/fn.catalog.php

Add:

'products.cost',

After:

'products.product_type',

And add:

'cost' => 'products.cost',

After:

'price' => 'prices.price',

4.) In skins/basic/admin/views/products/manage.tpl

I don't need the List Price on my manage page so I just replaced:

<th width="10%"><a class="{$ajax_class}{if $search.sort_by == "list_price"} sort-link-{$search.sort_order}{/if}" href="{"`$c_url`&sort_by=list_price&sort_order=`$search.sort_order`"|fn_url}" rev="pagination_contents">{$lang.list_price} ({$currencies.$primary_currency.symbol})</a></th>

With:

<th width="10%"><a class="{$ajax_class}{if $search.sort_by == "cost"} sort-link-{$search.sort_order}{/if}" href="{"`$c_url`&sort_by=cost&sort_order=`$search.sort_order`"|fn_url}" rev="pagination_contents">{$lang.cost} ({$currencies.$primary_currency.symbol})</a></th>

And I also replaced:

<td class="center">
		<input type="text" name="products_data[{$product.product_id}][list_price]" size="6" value="{$product.list_price}" class="input-text-medium" /></td>

With:

<td class="center">
		<input type="text" name="products_data[{$product.product_id}][cost]" size="6" value="{$product.cost}" class="input-text-medium" /></td>

If you want the List Price to stay, than just add my code as new code after the List Price or whatever. You'll also need to play around with the table column widths to make everything fit.

5.) In skins/basic/admin/views/products/update.tpl

Add:

<div class="form-field">
	<label for="product_cost" class="cm-required">Cost: ({$currencies.$primary_currency.symbol}) :</label>
	<input type="text" name="product_data[cost]" id="product_cost" size="10" value="{$product_data.cost|default:"0.00"}" class="input-text-medium" />
</div>

After:

<div class="form-field">
	<label for="price_price" class="cm-required">{$lang.price} ({$currencies.$primary_currency.symbol}) :</label>
	<input type="text" name="product_data[price]" id="price_price" size="10" value="{$product_data.price|default:"0.00"}" class="input-text-medium" />
</div>

6.) Upload your files and you are all done.

Hope that helps someone.

Brandon

 
  • elk
  • Member
  • Members
  • Join Date: 28-Jan 11
  • 92 posts

Posted 30 January 2011 - 12:21 AM #2

brandonvd and snorocket: you are the best

it was so easy to create. thanks a lot

some extra info:
if you want to make the width smaller: at the ../manage.tpl
at the
<input type="text" name="products_data[{$product.product_id}][cost]" size="6" value="{$product.cost}" class="input-text-medium" />
change the input-text-medium to input-text or input-text-short for even smaller

and i also add a column called "Profit" which shows "Price-vat-cost=profit"
to do this:
1.add a language var "name:profit value:Profit"
2.to the .../products/manage.tpl
after
 <th width="10%"><a class="{$ajax_class}{if $search.sort_by == "cost"} sort-link-{$search.sort_order}{/if}" href="{"`$c_url`&sort_by=cost&sort_order=`$search.sort_order`"|fn_url}" rev="pagination_contents">{$lang.cost} ({$currencies.$primary_currency.symbol})</a></th>

add
 <th width="10%">{$lang.myprofit}</th>

and after
 <td class="center">
<input type="text" name="products_data[{$product.product_id}][cost]" size="6" value="{$product.cost}" class="input-text" /></td>

add
<td class="center">{$product.price/1.23-$product.cost}</td>

where /1.23 = my vat 23%. if your vat is 17.5% change to /1.175 and if you don't apply vat to your prices then remove it and add {$product.price-$product.cost}

make sure to not add any space between / and -
my only problem with this is that i can't round the demicals to 2 (any help with this??)

i will try to add these to order details too, in order to see (the admin) the sold price and the cost price together and also add a final profit from order: $Sold price - VAT - $Cost price - $Shipping = $$ total earnings

i tried to do it but with no success. i add the extra columns to the ..../views/orders/details.tpl next to the price column, but it does not read the cost price. maybe i have to add something to the core/fn.cart.php
something like the above
'products.cost',
'cost' => 'products.cost',

Can you help me with that brandonvd ??

and i will also try to make an "Earnings Report" as well (to the "sales report" page)
Mylot.gr // Mobiles & Gadgets
CS-Cart 2.1.3 ver. working fine

 
  • snorocket
  • Forum Janitor
  • Members
  • Join Date: 15-Mar 06
  • 2519 posts

Posted 30 January 2011 - 02:50 PM #3

and i will also try to make an "Earnings Report" as well (to the "sales report" page)

We already have this addon finished for 2.1.2, however such as addon is a bit more complex then what is described above, their are many issues that can throw the reports off if not done correctly such as the COG of option variants. With the Profit Loss Addon you can create multiple reports based on any number of parameters such as reports by day, week, month, quarterly, yearly and customized time frames so you can view exactly how much money you are actually making (or losing) in realtime and this can be done on a per order basis or by a group of orders.

1. Each Product has a COG entry.
2. Accounts for COG of option variants.
3. Each Order has an actual shipping cost entry.
4. Profit or Loss is displayed on the order details.
5. COG History: When the COG of the product changes the previous COG will not change. This will stay the same according to how much the COG was when purchased and sold.
6. Ability to create and save custom profit loss reports.

http://www.snorocket...ss-reports.html

I'll try and get some screen shots up soon, Thanks - Sno
SNOROCKET.COM, Now Accepting PRE-ORDERS:
Customer Service (Helpdesk) Addon for CS-Cart v4.3.1
Quote and Invoicing Addon for CS-Cart v4.3.1

 
  • tuari
  • Junior Member
  • Members
  • Join Date: 22-Aug 09
  • 40 posts

Posted 09 February 2011 - 10:03 PM #4

We already have this addon finished for 2.1.2, however such as addon is a bit more complex then what is described above, their are many issues that can throw the reports off if not done correctly such as the COG of option variants.


Snorocket,

I placed an order for this addon on your website on Sunday, Feb. 6; however, the only communication I received was a confirmation from PayPal. I have not received any information from you regarding the delivery/download of the addon, nor have I received a response to the emails I have sent to you. You state above the addon is finished - is it currently available? If so, now that I have ordered it, when and how will I actually obtain it?

 
  • elk
  • Member
  • Members
  • Join Date: 28-Jan 11
  • 92 posts

Posted 10 February 2011 - 04:19 PM #5

my only problem with this is that i can't round the demicals to 2 (any help with this??)


found it. add substr:0:4}
changed to <td class="center">{$product.price/1.23-$product.cost|substr:0:4}</td>
this will read the first 5 letters (0,1,2,3,4 including dot) of the number. example. 13.56 or 132.5

(if you set it to :1:2:} it will read the second and the third number only. usefull if you want to make a var something like ....{if $product.cost|substr:1:2=="##"...)
Mylot.gr // Mobiles & Gadgets
CS-Cart 2.1.3 ver. working fine

 
  • vidan
  • Senior Member
  • Members
  • Join Date: 11-Jan 10
  • 373 posts

Posted 11 February 2011 - 06:05 AM #6

Snorocket,

I placed an order for this addon on your website on Sunday, Feb. 6; however, the only communication I received was a confirmation from PayPal. I have not received any information from you regarding the delivery/download of the addon, nor have I received a response to the emails I have sent to you. You state above the addon is finished - is it currently available? If so, now that I have ordered it, when and how will I actually obtain it?



tuari: you post in the wrong thread, should be in here: http://forum.cs-cart...newpost&t=20359
and the mod is not available, you just wait for the guy release it, if he said 1-2 weeks, from my experience, it should be around 1-2 months or more. so please keep on waiting.

 
  • tuari
  • Junior Member
  • Members
  • Join Date: 22-Aug 09
  • 40 posts

Posted 11 February 2011 - 01:55 PM #7

Thanks Vidan. Looks like I made 2 mistakes - the first was purchasing from snorocket.

 
  • Struck
  • Teetering on Genious
  • Members
  • Join Date: 07-Mar 09
  • 2502 posts

Posted 11 February 2011 - 10:58 PM #8

and the mod is not available, you just wait for the guy release it, if he said 1-2 weeks, from my experience, it should be around 1-2 months or more. so please keep on waiting.


Good Stuff!
100 Posts "Searching for a Custom Mod", and another 41 Posts "Complaining about the Mods you did find (& most likely never purchased even one of them along the way)"............ :shock:
Cooking with Gas on Version 4.1.2 (But proceeding with caution....)

 
  • snorocket
  • Forum Janitor
  • Members
  • Join Date: 15-Mar 06
  • 2519 posts

Posted 12 February 2011 - 12:30 AM #9

tuari: you post in the wrong thread, should be in here: http://forum.cs-cart...newpost&t=20359
and the mod is not available, you just wait for the guy release it, if he said 1-2 weeks, from my experience, it should be around 1-2 months or more. so please keep on waiting.


The Profit Loss Addon will be released Monday, if I see that vidan wants it I'll postpone it another month or so. I'm also working on a whiny complainers addon for vidan, unfortunately I'm unable to code an addon to get the knot outta his panties - Sno
SNOROCKET.COM, Now Accepting PRE-ORDERS:
Customer Service (Helpdesk) Addon for CS-Cart v4.3.1
Quote and Invoicing Addon for CS-Cart v4.3.1

 
  • Struck
  • Teetering on Genious
  • Members
  • Join Date: 07-Mar 09
  • 2502 posts

Posted 12 February 2011 - 02:38 AM #10

unfortunately I'm unable to code an addon to get the knot outta his panties


Yeah, some people don't realize that panties are not supposed to be worn over your head, creates reduced circulation I have been told.
Cooking with Gas on Version 4.1.2 (But proceeding with caution....)

 
  • snorocket
  • Forum Janitor
  • Members
  • Join Date: 15-Mar 06
  • 2519 posts

Posted 12 February 2011 - 05:17 AM #11

We found a minor bug during beta testing and will now have a Tues/Wed release date - Sno
SNOROCKET.COM, Now Accepting PRE-ORDERS:
Customer Service (Helpdesk) Addon for CS-Cart v4.3.1
Quote and Invoicing Addon for CS-Cart v4.3.1

 
  • lcbo
  • Junior Member
  • Members
  • Join Date: 12-Feb 11
  • 5 posts

Posted 12 February 2011 - 08:30 AM #12

Thank you for the tutorial.
I am completely new to CS Cart.

Can you guide me how to show products_cost on the front page as well
(I modified the filed in order to show another information, that i need on storefront)

Thank you so much.

LATER EDIT: I did it. Thank you

 
  • elk
  • Member
  • Members
  • Join Date: 28-Jan 11
  • 92 posts

Posted 14 February 2011 - 09:13 AM #13

how to show product_cost in the order details(admin) and in the front-page or sales reports.
i add it at the orders/details.tpl file but it doesn't "read" the number
do i have to add something in the fn.???.php files ? like the fn.catalog.php changes?
Mylot.gr // Mobiles & Gadgets
CS-Cart 2.1.3 ver. working fine

 
  • jegesmaci
  • Senior Member
  • Members
  • Join Date: 05-Oct 09
  • 403 posts

Posted 15 February 2011 - 04:25 PM #14

We found a minor bug during beta testing and will now have a Tues/Wed release date - Sno


Sno,

I am interested in this mod. Do you have any screenshots?

Adam

 
  • snorocket
  • Forum Janitor
  • Members
  • Join Date: 15-Mar 06
  • 2519 posts

Posted 15 February 2011 - 05:00 PM #15

Sno,

I am interested in this mod. Do you have any screenshots?

Adam


Sure, here they are, we found a minor miscalculation with the addon and we are having it fixed, the updated version will be available for download soon, Thanks - Sno

Posted Image

Posted Image
Posted Image
Posted Image
SNOROCKET.COM, Now Accepting PRE-ORDERS:
Customer Service (Helpdesk) Addon for CS-Cart v4.3.1
Quote and Invoicing Addon for CS-Cart v4.3.1

 
  • sh1nn3r
  • Member
  • Members
  • Join Date: 19-Nov 09
  • 85 posts

Posted 15 February 2011 - 08:21 PM #16

Hey Sno - When you mean soon is that today? I would really like to get this addon rolling.

Thanks

 
  • elk
  • Member
  • Members
  • Join Date: 28-Jan 11
  • 92 posts

Posted 15 February 2011 - 08:29 PM #17

>does the profit loss report appear at the admin front-page too?
>is it easily to make the profit loss be like this:
Order ###: Sold price | Tax | Shiping cost | Products cost | profit
for example (vat 10%)
Order #1 : $200 | $18 | $12 | $50 | $120
Order #2 : $100 | $9 | $11 | $30 | $50
Total:
Orders 2: $300 | $27 | $23 | $80 | $170
Mylot.gr // Mobiles & Gadgets
CS-Cart 2.1.3 ver. working fine

 
  • snorocket
  • Forum Janitor
  • Members
  • Join Date: 15-Mar 06
  • 2519 posts

Posted 15 February 2011 - 08:32 PM #18

Hey Sno - When you mean soon is that today? I would really like to get this addon rolling.

Thanks

Yes, late this evening - Sno
SNOROCKET.COM, Now Accepting PRE-ORDERS:
Customer Service (Helpdesk) Addon for CS-Cart v4.3.1
Quote and Invoicing Addon for CS-Cart v4.3.1

 
  • snorocket
  • Forum Janitor
  • Members
  • Join Date: 15-Mar 06
  • 2519 posts

Posted 15 February 2011 - 08:32 PM #19

>does the profit loss report appear at the admin front-page too?
>is it easily to make the profit loss be like this:
Order ###: Sold price | Tax | Shiping cost | Products cost | profit
for example (vat 10%)
Order #1 : $200 | $18 | $12 | $50 | $120
Order #2 : $100 | $9 | $11 | $30 | $50
Total:
Orders 2: $300 | $27 | $23 | $80 | $170

We can add this functionality - Sno
SNOROCKET.COM, Now Accepting PRE-ORDERS:
Customer Service (Helpdesk) Addon for CS-Cart v4.3.1
Quote and Invoicing Addon for CS-Cart v4.3.1

 
  • 2020
  • Senior Member
  • Members
  • Join Date: 11-Feb 07
  • 509 posts

Posted 15 February 2011 - 08:35 PM #20

I've purchased the mod and am really looking forward to seeing the functionality. Thanks Sno!

-Glen