Jump to content
Sign in to follow this  
Mike

New Feature - Sales Report

Recommended Posts

Hi, 

Sorry I'm using this as your new Feature option isn't available.

I am quite surprised this isn't already been requested.

I along with a lot of other people need to know the profits generated when products are sold.

A report generated that will get information stored from when a product is sold. This will show Date Sold, Item Sold, Price Sold, Cost Price and Details of who purchased it.

Other option could be available on the report.

At the moment, I can not see that the cost price is recorded at the time of the sale.

Could this be considered for a future upgrade please.

I wouldn't mind if there is a small charge as an add on extension.

This is something that I feel is needed for a lot of people when it comes to profits and tax purposes.

Regards

Mike 

 

Share this post


Link to post
Share on other sites

It isnt a bug and github isnt the right place for it but also the features website seems to be working fine for me https://features.cubecart.com/ 

You might want to look at https://www.cubecart.com/extensions/plugins/dashboard-widgets-and-advanced-reports by @Noodleman as he has stated that he would be happy to add additional reports as / when required

Share this post


Link to post
Share on other sites

Now it's working! (Wasn't in the past every time I tried it - latest was yesterday.)

Share this post


Link to post
Share on other sites

I have had a look and test the Advanced Reporting. It looks very good and gives all the details that I need except one issue with it.

If you sell a product for £30 and the cost is £20 this gives £10 profit. This is fine. But.. If you sell the same product after a a few days and the cost price has now gone down to £15 then the first time you sold it and the second time you sold will show a profit of £15.

This is not a true representative of the profit for the first time sold.

It needs to be stamped and kept at the time of the sale.

Any ideas? The  simple solution is as bsmither said earlier.

Share this post


Link to post
Share on other sites

Record Cost Price to CubeCart_inventory at time of sale.

Execute the following SQL statement. Be sure to prepend the table name with any table prefix being used.

ALTER TABLE `CubeCart_order_inventory` ADD COLUMN `cost_price` DECIMAL(16,2) NOT NULL DEFAULT '0.00' AFTER `price`;


In /classes/cart.class.php, near line 392, find:

foreach ($GLOBALS['hooks']->load('class.cart.add.save') as $hook) include $hook;

On the blank line above, add:

$this->basket['contents'][$hash]['cost_price'] = $product['cost_price'];


In /classes/order.class.php, near line 1232, find:

foreach ($GLOBALS['hooks']->load('class.order.products.add.pre') as $hook) include $hook;

On the blank line above, add:

$record['cost_price'] = $item['cost_price'];

Now that 'cost_price' of the item, collected at the time of the sale, is recorded, this data can be shown elsewhere, and used by other plugins.

Keep these instructions! These are edits to core code and will not survive an upgrade.

Note that each edit is next to a hook loader. We could, in fact, use these hooks which would offer the benefit of having this new feature survive an upgrade.

If you are interested in learning more about hooks, please start with this:
https://support.cubecart.com/Knowledgebase/Article/View/203/46/how-can-i-create-a-plugin-using-the-code-hooks-system

Then, we can move over to Code Snippets.

 

Edited by bsmither

Share this post


Link to post
Share on other sites

That's brilliant bsmither.

This needs to be incorporated along with the advanced reporting.

I can work with this and get the profit margins from each sale by reports from sql.

I have tested it and it works perfect.

As far as hooks go... I've read the link, but it lost me. I know the principle now and I agree it would be better so an update doesn't effect it but I wouldn't know where to start.

 

Just one other thing, when I was testing your code changes, I wanted to know at what point it creates the transaction in the order inventory table. 

Why does the checkout system asks you to complete your order after payment has been done?

Why does it ask that?

Has payment been made at that point if so why ask you to click to complete payment? At that point you have been passed back from eg. paypal.

The order is still in the system even if you don't click on the button to complete it and click on the home button.

Just wondered why it asks?

Thank you again for that coding and changes for the cost price you're a star.

 

Mike

 

Share this post


Link to post
Share on other sites
13 hours ago, Mike said:

I have had a look and test the Advanced Reporting. It looks very good and gives all the details that I need except one issue with it.

If you sell a product for £30 and the cost is £20 this gives £10 profit. This is fine. But.. If you sell the same product after a a few days and the cost price has now gone down to £15 then the first time you sold it and the second time you sold will show a profit of £15.

This is not a true representative of the profit for the first time sold.

It needs to be stamped and kept at the time of the sale.

Any ideas? The  simple solution is as bsmither said earlier.

I'll check into this. It should be pulling historic data

Share this post


Link to post
Share on other sites

Hi Noodleman,

As the cost is not recorded at the time of sale, I don't think it is possible.

The adaptation that I have put in from bsmither now records the cost price at the time of sale.

Let me know how you go on with it.

 

Share this post


Link to post
Share on other sites
1 minute ago, Mike said:

Hi Noodleman,

As the cost is not recorded at the time of sale, I don't think it is possible.

The adaptation that I have put in from bsmither now records the cost price at the time of sale.

Let me know how you go on with it.

 

It should be doing this already, although looks like it's still on the roadmap. although, I thinking back, I believe I was waiting on this to be added into the Core CubeCart engine. I've had the requests open with CubeCart since 2015.... since those didn't happen the module didn't get updated. 

https://github.com/cubecart/v6/issues/619

https://github.com/cubecart/v6/issues/620

https://github.com/cubecart/v6/issues/622

I'll update the module to capture all these details

Share this post


Link to post
Share on other sites

Excellent.

Let me know when you have and I will test it for you.

Once that's in place and I'm setup I will get the advanced reporting.

Cheers

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...