Jump to content

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

Add Product Cost Price Field In Backend Rate Topic   * * * * * 1 votes

 
  • ibaker
  • Senior Member
  • Members
  • Join Date: 23-Oct 06
  • 270 posts

Posted 05 March 2014 - 09:46 PM #1

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.

Attached File  1.jpg   54.47KB   187 downloads Attached File  2.jpg   24.11KB   191 downloads

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
1. 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
<th width="45%"><a class="cm-ajax" href="{"`$c_url`&sort_by=product&sort_order=`$search.sort_order_rev`"|fn_url}" data-ca-target-id={$rev}>{__("name")}
and add after that
<th width="10%"><a class="cm-ajax" href="{"`$c_url`&sort_by=cost&sort_order=`$search.sort_order_rev`"|fn_url}" data-ca-target-id={$rev}>{__("cost")} ({$currencies.$primary_currency.symbol nofilter}){if $search.sort_by == "cost"}{$c_icon nofilter}{else}{$c_dummy nofilter}{/if}</a></th>

b.) Find
<th width="15%"><a class="cm-ajax" href="{"`$c_url`&sort_by=price&sort_order=`$search.sort_order_rev`"|fn_url}" data-ca-target-id={$rev}>{__("price")}
and change the 15% to 10%

c.) Find
<th width="15%"><a class="cm-ajax" href="{"`$c_url`&sort_by=list_price&sort_order=`$search.sort_order_rev`"|fn_url}" data-ca-target-id={$rev}>
and change the 15% to 10%

d.) Find
{include file="views/companies/components/company_name.tpl" object=$product}
</td>
and add after that
<td>
	<input type="text" name="products_data[{$product.product_id}][cost]" size="6" value="{$product.cost}" class="input-mini input-hidden" />
</td>

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:
Attached File  3.jpg   40.68KB   116 downloads

OPTION 1
a.) Find
<div class="control-group">
	<label class="control-label" for="elm_product_code">{__("sku")}:</label>
	<div class="controls">
		<input type="text" name="product_data[product_code]" id="elm_product_code" size="20" maxlength="32"  value="{$product_data.product_code}" class="input-long" />
	</div>
</div>
and add after that
<div class="control-group">
	<label class="control-label" for="elm_cost">{__("cost")} ({$currencies.$primary_currency.symbol nofilter}):</label>
	<div class="controls">
		<input type="text" name="product_data[cost]" id="elm_cost" size="10" value="{$product_data.cost|default:"0.00"}" class="input-long" />
	</div>
</div>

OPTION 2
a.) Find
<div class="control-group {$no_hide_input_if_shared_product}">
	<label for="elm_price_price" class="control-label cm-required">{__("price")} ({$currencies.$primary_currency.symbol nofilter}):</label>
	<div class="controls">
		<input type="text" name="product_data[price]" id="elm_price_price" size="10" value="{$product_data.price|default:"0.00"|fn_format_price:$primary_currency:null:false}" class="input-long" />
		{include file="buttons/update_for_all.tpl" display=$show_update_for_all object_id='price' name="update_all_vendors[price]"}
	</div>
</div>
and add BEFORE that
<div class="control-group">
	<label class="control-label" for="elm_cost">{__("cost")} ({$currencies.$primary_currency.symbol nofilter}):</label>
	<div class="controls">
		<input type="text" name="product_data[cost]" id="elm_cost" size="10" value="{$product_data.cost|default:"0.00"}" class="input-long" />
	</div>
</div>

b.) Find
<div class="control-group">
	<label class="control-label" for="elm_list_price">{__("list_price")} ({$currencies.$primary_currency.symbol nofilter}) :</label>
	<div class="controls">
		<input type="text" name="product_data[list_price]" id="elm_list_price" size="10" value="{$product_data.list_price|default:"0.00"}" class="input-long" />
	</div>
</div>
Cut that code out and paste it in after
<div class="control-group {$no_hide_input_if_shared_product}">
	<label for="elm_price_price" class="control-label cm-required">{__("price")} ({$currencies.$primary_currency.symbol nofilter}):</label>
	<div class="controls">
		<input type="text" name="product_data[price]" id="elm_price_price" size="10" value="{$product_data.price|default:"0.00"|fn_format_price:$primary_currency:null:false}" class="input-long" />
		{include file="buttons/update_for_all.tpl" display=$show_update_for_all object_id='price' name="update_all_vendors[price]"}
	</div>
</div>

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

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1426 posts

Posted 23 March 2014 - 08:07 PM #2

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 http://www.cscart.biz/product-286.html

Fotis
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • ibaker
  • Senior Member
  • Members
  • Join Date: 23-Oct 06
  • 270 posts

Posted 23 March 2014 - 09:37 PM #3

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

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1426 posts

Posted 23 March 2014 - 11:24 PM #4

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
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • dmciver
  • Newbie
  • Members
  • Join Date: 04-Feb 14
  • 2 posts

Posted 27 March 2014 - 04:12 PM #5

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 fn.catalog.php?

I'm still very new at CS-Cart - but appreciate the user contributions!

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 :-)

Attached File  COGS add-on.zip   160.42KB   81 downloads

 
  • ibaker
  • Senior Member
  • Members
  • Join Date: 23-Oct 06
  • 270 posts

Posted 27 March 2014 - 08:30 PM #6

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

 
  • Gizmo
  • Junior Member
  • Members
  • Join Date: 05-Jan 09
  • 141 posts

Posted 28 March 2014 - 10:18 AM #7

Hi DVS I purchased the addon it shows failed. Payment went through order #700
[center]www.vapeking.co.za[/center]

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1426 posts

Posted 28 March 2014 - 10:20 AM #8

Hi Gizmo

I already took action, email me at info@dvs.gr
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • londonman
  • Member
  • Members
  • Join Date: 27-Oct 10
  • 196 posts

Posted 27 June 2014 - 05:03 PM #9

hi lan,

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

Thank,

Jack

 
  • londonman
  • Member
  • Members
  • Join Date: 27-Oct 10
  • 196 posts

Posted 27 June 2014 - 06:04 PM #10

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

 
  • vivophone
  • Junior Member
  • Members
  • Join Date: 09-Sep 06
  • 23 posts

Posted 03 July 2014 - 05:12 AM #11

Hi,
Would it be easier to use the Features Tab. You can put the UPC or EAN Code there
www.software-only.com.au Live
CS-Cart 2.1.11

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

Posted 03 July 2014 - 05:43 AM #12

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

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



 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1426 posts

Posted 03 July 2014 - 05:57 AM #13

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
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • londonman
  • Member
  • Members
  • Join Date: 27-Oct 10
  • 196 posts

Posted 03 July 2014 - 07:12 AM #14

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


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.

 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1426 posts

Posted 03 July 2014 - 08:36 AM #15

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.


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
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • ibaker
  • Senior Member
  • Members
  • Join Date: 23-Oct 06
  • 270 posts

Posted 05 August 2014 - 11:39 PM #16

Note: This seems to work ok for v4.2.1

 
  • simonv74
  • Member
  • Members
  • Join Date: 27-Aug 08
  • 84 posts

Posted 21 July 2015 - 01:00 PM #17

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

 
  • torbikua
  • Newbie
  • Members
  • Join Date: 12-Nov 13
  • 2 posts

Posted 19 August 2015 - 05:46 AM #18

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

 
  • Onkel_Sid
  • Junior Member
  • Members
  • Join Date: 04-Sep 10
  • 301 posts

Posted 19 August 2015 - 06:02 AM #19

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.uservo...reports-on-sale

Stop smoking start vaping: Dampskyen.no


 
  • Consultant
  • Member
  • Members
  • Join Date: 15-May 10
  • 168 posts

Posted 03 June 2016 - 06:11 PM #20

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?