Mod to add cost field

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 [url]http://www.snorocket.com/forums/showthread.php?262-How-to-add-a-new-product-field-to-the-product-details-page[/url].



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:


{$lang.list_price} ({$currencies.$primary_currency.symbol})



With:


{$lang.cost} ({$currencies.$primary_currency.symbol})



And I also replaced:







With:







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:


```php



Cost: ({$currencies.$primary_currency.symbol}) :


```

After:

```php

{$lang.price} ({$currencies.$primary_currency.symbol}) :

```

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

Hope that helps someone.

Brandon

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



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

[HTML] $c_url&sort_by=cost&sort_order=$search.sort_order"|fn_url}" rev=“pagination_contents”>{$lang.cost} ({$currencies.$primary_currency.symbol})[/HTML]

add

[HTML] {$lang.myprofit}[/HTML]

and after

[HTML]

[/HTML]

add

[HTML]{$product.price/1.23-$product.cost}[/HTML]

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)

[quote name=‘elk’]and i will also try to make an “Earnings Report” as well (to the “sales report” page)[/quote]

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.



    [URL]http://www.snorocket.com/addons/profit-loss-reports.html[/URL]



    I’ll try and get some screen shots up soon, Thanks - Sno

[quote name=‘snorocket’]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. [/QUOTE]



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?

[quote name=‘elk’]my only problem with this is that i can’t round the demicals to 2 (any help with this??)[/QUOTE]



found it. add substr:0:4}

changed to {$product.price/1.23-$product.cost[COLOR=“Red”]|substr:0:4[/COLOR]}

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==“##”…)

[quote name=‘tuari’]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?[/QUOTE]





tuari: you post in the wrong thread, should be in here: [url]http://forum.cs-cart.com/showthread.php?goto=newpost&t=20359[/url]

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.

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

[QUOTE]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.[/QUOTE]



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:

[quote name=‘vidan’]tuari: you post in the wrong thread, should be in here: [URL]http://forum.cs-cart.com/showthread.php?goto=newpost&t=20359[/URL]

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.[/quote]



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

[QUOTE]unfortunately I’m unable to code an addon to get the knot outta his panties [/QUOTE]



Yeah, some people don’t realize that panties are not supposed to be worn over your head, creates reduced circulation I have been told.

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

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

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?

[quote name=‘snorocket’]We found a minor bug during beta testing and will now have a Tues/Wed release date - Sno[/QUOTE]



Sno,



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



Adam

[quote name=‘jegesmaci’]Sno,



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



Adam[/quote]



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











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



Thanks

does the profit loss report appear at the admin front-page too?

is it easily to make the profit loss be like this:

Order ###: [COLOR=“Blue”]Sold price[/COLOR] | [COLOR=“seagreen”]Tax [/COLOR]| [COLOR=“Black”]Shiping cost[/COLOR] | [COLOR=“purple”]Products cost [/COLOR]| [COLOR=“Red”]profit[/COLOR]

for example (vat 10%)

Order #1 : $[COLOR=“Blue”]200[/COLOR] | $[COLOR=“SeaGreen”]18[/COLOR] | $[COLOR=“Black”]12[/COLOR] | $[COLOR=“Purple”]50[/COLOR] | $[COLOR=“Red”]120[/COLOR]

Order #2 : $[COLOR=“Blue”]100[/COLOR] | $[COLOR=“SeaGreen”]9[/COLOR] | $[COLOR=“Black”]11 [/COLOR]| $[COLOR=“Purple”]30[/COLOR] | $[COLOR=“Red”]50[/COLOR]

Total:

Orders 2: $[COLOR=“Blue”]300[/COLOR] | $[COLOR=“seaGreen”]27[/COLOR] | $[COLOR=“Black”]23[/COLOR] | $[COLOR=“Purple”]80[/COLOR] | $[COLOR=“Red”]170[/COLOR]

[quote name=‘sh1nn3r’]Hey Sno - When you mean soon is that today? I would really like to get this addon rolling.



Thanks[/quote]

Yes, late this evening - Sno

[quote name=‘elk’]>does the profit loss report appear at the admin front-page too?

is it easily to make the profit loss be like this:

Order ###: [COLOR=Blue]Sold price[/COLOR] | [COLOR=seagreen]Tax [/COLOR]| [COLOR=Black]Shiping cost[/COLOR] | [COLOR=purple]Products cost [/COLOR]| [COLOR=Red]profit[/COLOR]

for example (vat 10%)

Order #1 : $[COLOR=Blue]200[/COLOR] | $[COLOR=SeaGreen]18[/COLOR] | $[COLOR=Black]12[/COLOR] | $[COLOR=Purple]50[/COLOR] | $[COLOR=Red]120[/COLOR]

Order #2 : $[COLOR=Blue]100[/COLOR] | $[COLOR=SeaGreen]9[/COLOR] | $[COLOR=Black]11 [/COLOR]| $[COLOR=Purple]30[/COLOR] | $[COLOR=Red]50[/COLOR]

Total:

Orders 2: $[COLOR=Blue]300[/COLOR] | $[COLOR=seaGreen]27[/COLOR] | $[COLOR=Black]23[/COLOR] | $[COLOR=Purple]80[/COLOR] | $[COLOR=Red]170[/COLOR][/quote]

We can add this functionality - Sno

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



-Glen