Add Product Cost Price Field In Backend

I needed to have a product “Cost Price” field added next to the Price and List Price fields in the products area of the CS-Cart admin (not displayed in the shop front end) so I could record the last cost price of a product.



I am using CS-Cart v4.1.2 and thanks to brandonvd I was able to do it in v2.2.5 however there has been no update for v4.1.2 so I have adapted Brandon's tutorial for v4.1.2 and post it here to help others who may also want the same thing.



These changes will add an editable Cost field next to the Price field in the product list (Products → Products) and also add an editable Cost field when creating or editing a product.



[attachment=7808:1.jpg] [attachment=7809:2.jpg]



NOTES:

  1. This does include adding a couple of lines in a core CS-Cart file so if you update your CS-Cart version it will most probably overwrite the changes so you will need to reapply the changes again
  2. This has some limitations such as:

    a.) Not included in the field list of product data imports or exports

    b.) Doesn't have separate cost field for product options

    c.) and possibly some other areas that I don't have a need for personally so I haven't looked where to apply other changes.



    Installation
  3. We need to first create a Cost field in the cscart_products table of our database. So copy the following code and in phpMyAdmin select your database and paste the code in the SQL area and run it. Check that a new field “cost” has been added to your cscart_products table after the product_code field.

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



2. Add a language entry for Cost in Administration → Languages → Translations. Add a new entry with these details:

Language variable: cost

Value: Cost



3. This is where we add some lines into a core CS-Cart file.

a.) Open the fn.catalog.php file located at \app\functions



b.) Find

'products.company_id',

and add after it

'products.cost',



c.) Find

'price' => 'price',

and add after it

'cost' => 'products.cost',



d.) Find

array(
'name' => '[data][price]',
'text' => __('price')
),


and add after it

array(
'name' => '[data][cost]',
'text' => __('cost')
),




4. Open the manage.tpl template located at \design\backend\templates\views\products

a.) Find

{__("name")}

and add after that

{__("cost")} ({$currencies.$primary_currency.symbol nofilter}){if $search.sort_by == "cost"}{$c_icon nofilter}{else}{$c_dummy nofilter}{/if}



b.) Find

{__("price")}

and change the 15% to 10%



c.) Find



and change the 15% to 10%



d.) Find

```php {include file=“views/companies/components/company_name.tpl” object=$product}

```
and add after that
```php

```

5. Open the update.tpl template located at \design\backend\templates\views\products
There are 2 options that you may like to use here. The first option places the Cost field above the List Price field in the Pricing/Inventory section of the product entry/edit page, as in the screen shot above. Option 2 places the Cost field above the Price field and moves the List Price field below the Price field keeping all the prices together as in this screen shot:
[attachment=7810:3.jpg]

[b]OPTION 1[/b]
a.) Find
```php

{__("sku")}:



```
and add after that
```php

{__("cost")} ({$currencies.$primary_currency.symbol nofilter}):



```

[b]OPTION 2[/b]
a.) Find
```php

{__("price")} ({$currencies.$primary_currency.symbol nofilter}):


{include file="buttons/update_for_all.tpl" display=$show_update_for_all object_id='price' name="update_all_vendors[price]"}

```
and add BEFORE that
```php

{__("cost")} ({$currencies.$primary_currency.symbol nofilter}):



```

b.) Find
```php

{__("list_price")} ({$currencies.$primary_currency.symbol nofilter}) :



```
Cut that code out and paste it in after
```php

{__("price")} ({$currencies.$primary_currency.symbol nofilter}):


{include file="buttons/update_for_all.tpl" display=$show_update_for_all object_id='price' name="update_all_vendors[price]"}

```

6. That's it...please test to make sure it is working ok

Hope you find this helpful and I encourage others to make their solutions available to everyone else

2.jpg

1.jpg

3.jpg

Hi



For those who cant do this we have a ready made addon that has also some extra features like margin calculation and import/export cost via csv



Find more at [url=“Τιμή Προμηθευτή και Κέρδος - CS-Cart Addons/Πρόσθετα at Cscart.Biz | CS-Cart Market by Dvs.gr”]http://www.cscart.biz/product-286.html[/url]



Fotis

WOW, 65 Euro, that's $100 Australian…a bit steep in price there mate but thanks anyway

Hi there Ian



It is a fairly complex Addon .

You got import and export via csv but most of all on the fly calculation of profit margin in the product screen(via Ajax)



Have a look here https://www.youtube…e2g4mZv4sw#t=71



Fotis

Thanks for the tutorial - I don’t like touching the core files, so I modified the 2 tpl files and made a custom add-on to load them. Is there a way to avoid touching the core [color=#282828][font=arial, verdana, tahoma, sans-serif]fn.catalog.php?[/font][/color]



[color=#282828][font=arial, verdana, tahoma, sans-serif]I’m still very new at CS-Cart - but appreciate the user contributions![/font][/color]



[color=#282828][font=arial, verdana, tahoma, sans-serif]I’ve attached my mods and notes… hopefully one of you smart guys out there can take the ball the rest of the way across the line for me / us :-)[/font][/color]



[attachment=7859:COGS add-on.zip]

COGS add-on.zip

The fn.catalog.php is the main tool used to get the data from the database to the template files and then save the cost data back into the database. Sorry but I can't help with bypassing this as I am not a developer as such. I personally don't have an issue with it as they are small changes and I just reinsert the changes after any CS-Cart updates

Hi DVS I purchased the addon it shows failed. Payment went through order #700

Hi Gizmo



I already took action, email me at info@dvs.gr

hi lan,



can i use this way to add a new filed for UPC / EAN code?



Thank,



Jack

i did it.

it shows a filed for UPC but i met two problem.

  1. the code i insert shows in currency format.
  2. the field does not show up in the front sotre



    Really appreciate your help on this.



    Sincerely,



    Jack

Hi,

Would it be easier to use the Features Tab. You can put the UPC or EAN Code there

Hi Fotis -



Does your margin addon support Option Variant Modifiers? For instance, XXXL shirt costs $2 more for the consumer but supplier price $1 more.



thanks,

Glen


[quote name='dvsgr' timestamp='1395617081' post='179958']

Hi there Ian



It is a fairly complex Addon .

You got import and export via csv but most of all on the fly calculation of profit margin in the product screen(via Ajax)



Have a look here https://www.youtube…e2g4mZv4sw#t=71



Fotis

[/quote]

Hi Glen



No we don't support that, I but I can Customize this for you.



Just pm me a detailed description on how you want this to work.





Fotis

[quote name='vivophone' timestamp='1404364328' post='186873']

Hi,

Would it be easier to use the Features Tab. You can put the UPC or EAN Code there

[/quote]



thanks for the tip.



if i use the feature, it will kill more time when i do bulk uploading… that is why i want to get column for the UPC and other by adding a new field.

[quote name='londonman' timestamp='1404371547' post='186885']

thanks for the tip.



if i use the feature, it will kill more time when i do bulk uploading… that is why i want to get column for the UPC and other by adding a new field.

[/quote]



Hi londoman



if you want to insert another code we have this addon http://www.cscart.bi…routz-mpn.html It works exaclty as the SKU (searchable, mass import/export) and is shows up in the client product screen.



Is this something for you?



Fotis

Note: This seems to work ok for v4.2.1

Does anybody know how to get this to work for v 4.3.1?



The code:

'products.company_id',



Does not exist in fn.catalog.php

I have a fully working module that adds Incoming price column in backend. It allows you to import-export this value…

Working with: 4.1.x-4.3.x

This really should be implemented by CS-Cart a long time ago. Im amazed we need add ons for such a basic shopping cart feature.



Please vote for it here:

http://cscart.uservoice.com/forums/134344-cs-cart/suggestions/561057-ability-for-profit-calculation-and-reports-on-sale

I have a fully working module that adds Incoming price column in backend. It allows you to import-export this value...
Working with: 4.1.x-4.3.x

Why in the world would you post this and not provide info on how to get the module?