Sylius icon indicating copy to clipboard operation
Sylius copied to clipboard

Cost price on product variant entity

Open loevgaard opened this issue 4 years ago • 21 comments

I would ❤️ to have cost price on the product variant. Would this be something you would be interested in if I create a PR?

loevgaard avatar Oct 26 '21 10:10 loevgaard

I did that in combination with https://github.com/BabDev/supplier-plugin, so I have cost per supplier per variant.

vvasiloi avatar Oct 26 '21 11:10 vvasiloi

I also have the cost price plugin, but it's an overkill for just one property :D

I like the idea of having a cost price per supplier, but I would still vote for a simple cost price on the product variant because I believe that 90%+ of merchants will only have one supplier per item and hence one cost price.

loevgaard avatar Oct 26 '21 11:10 loevgaard

Hi! In 1.11 we have added the "Minimum Price" field on the Product Variant's channel pricing. I believe it may be used as the cost price also. At Sylius we are not planning to add any other similar fields to the pricing at the moment.

Please reopen if you have any remarks 🖖🏻

CoderMaggie avatar Mar 07 '22 12:03 CoderMaggie

Could you reopen this issue, Maggie? Minimum price has nothing to do with cost price. If you never want to add a cost price, then please don't reopen, but I think for such a simple field that maybe 90-95% shops will have on all their products, it is bad prioritization. At least I would love to hear the arguments against such a property.

loevgaard avatar Mar 07 '22 13:03 loevgaard

Sure, reopened. 👌🏻 In my opinion "cost price" (as I understand it) can have a lot to do with "minimum price". But it all depends on the use-cases and these no one has mentioned in this issue yet.

Could you give some more context then? Especially on what is this price used for?

Any examples from other platforms maybe?

CoderMaggie avatar Mar 07 '22 13:03 CoderMaggie

The cost price is the price, the store owner pays for the product.

EXAMPLE

Black Jeans
Cost price: $10
Price: $20

Profit = Price - Cost price = $10

Other platforms Shopify: https://shopify.dev/api/examples/product-cost

loevgaard avatar Mar 07 '22 13:03 loevgaard

Just adding a property is a good start, but ideally it should also be used in the order processing. Example from real project:

  • Each SKU has a cost (like purchasing or manufacturing price)
  • There are processing costs
  • There are shipping costs
  • There are order processors that calculate and save those costs (just like Sylius\Component\Core\OrderProcessing\OrderPricesRecalculator does with the product variant price)
  • There's a processor that calculates the profit based on order totals and the previously calculated costs and saves it on order
  • The profit can be shown on order, in dashboard (statistics chart), exported to a CRM or other external system, or sent to Google Analytics (or similar tools) instead of order total.

vvasiloi avatar Mar 07 '22 14:03 vvasiloi

Okay, I would suggest making a plugin out of it. Like a ProfitsPlugin? That would not only have the cost price field but also a module to calculate and report the profits.

In my opinion, this is not something 70-90% of shops would use as it often happens in other systems.

Maybe a feature request to this plugin - https://github.com/odiseoteam/SyliusReportPlugin ?

CoderMaggie avatar Mar 08 '22 11:03 CoderMaggie

So what Victor is suggesting, Maggie, is a great idea, but as you can see it starts with the cost price on the variant ;)

Victor suggested I create PRs to Sylius instead of creating plugins all the time (not entirely what he said :D). Would you accept a PR for the cost price? :)

loevgaard avatar Mar 24 '22 09:03 loevgaard

In my opinion, even if it would be nice to provide this costPrice in Core feature, it would make 0 sense without what Victor proposed as well. Just remember the originalPrice feature when it was not used anywhere (not even in templates).

But having those features in the core would be nice. I agree @CoderMaggie that not all the store would need that. But then thinking this way, you can remove a lot of features as well :smile:

Having them on core would imo make sense, and would not be that hard to maintain. Sylius has to start implementing more of those features that not everyone use, but still a majority would.

Roshyo avatar Mar 29 '22 08:03 Roshyo

@Roshyo: It's a bold statement to say it makes 0 sense to have the cost price without anything else :D I, on the contrary, think it makes perfect sense 🎉

loevgaard avatar Mar 29 '22 08:03 loevgaard

Just want to put some arguments out there, so you can see what I mean. With only the cost price, it's possible to:

  • Enforce price rules on products (i.e. a product editor is not allowed to set the product price below a certain margin)
  • Do simple profit reports
  • Create inventory reports (i.e. what's our inventory worth in total costs)

If I used 10 more minutes I could probably think of three other things ;)

loevgaard avatar Mar 29 '22 08:03 loevgaard

I agree with Stephane on this one. Adding just the property will have the same effects as the original price. It will create confusion, a lot of questions on support channels, issues and PRs trying to make it work and at least 3 community plugins I would either add at least a minimal foundation for using the property or not add anything at all.

vvasiloi avatar Mar 29 '22 09:03 vvasiloi

I suggested to Stephane that I could create a 'profit card' in the order show page in admin :)

loevgaard avatar Mar 29 '22 09:03 loevgaard

That would be a good start. It will require some order processing logic, similar to how it's not done with original price.

vvasiloi avatar Mar 29 '22 09:03 vvasiloi

Enforce price rules on products (i.e. a product editor is not allowed to set the product price below a certain margin)

This ☝🏻 should be done based on the minimum price of a variant 😅


  • the profit report is a must for this field to be useful, I agree. We could maybe add it to the dashboard, wdyt?
  • binding it with the suppliers (which we also don't have, and it would totally make sense to wrap it in a plugin 😅) - for having a cost per supplier?
  • is this channel-agnostic? I mean is the cost price global or per channel?

CoderMaggie avatar Mar 30 '22 10:03 CoderMaggie

I would love to add this property along with the small report card on the order.

is this channel-agnostic? I mean is the cost price global or per channel?

Imo it should be channel agnostic. It should be on the product variant.

loevgaard avatar Mar 31 '22 09:03 loevgaard

Prestashop also supports this. In their case the variant field is increasing the base product price, but a lot of my clients use zero as product price, and then set that price increase to the real product's price.

I actually found this because I'm currently trying to convince some of my clients to migrate from prestashop to sylius, and this is a must for them (I guess I'll try to create a plugin in the meantime tho).

elboletaire avatar Jun 30 '22 12:06 elboletaire

I am thinking 1.12, @CoderMaggie, what are you thinking? 😉

loevgaard avatar Jul 08 '22 13:07 loevgaard

Is this then planned for the upcoming 1.12? Or was just a thought? 😅

elboletaire avatar Sep 10 '22 15:09 elboletaire

@elboletaire https://github.com/Setono/SyliusCostPricePlugin

vvasiloi avatar Sep 11 '22 07:09 vvasiloi

Hi Folks, just FYI, we do not plan this feature for Sylius 1.12, we'll see what the future holds 💃

Rafikooo avatar Sep 27 '22 17:09 Rafikooo

Thank you for the update. Looking forward to 1.13 then ;)))

loevgaard avatar Sep 30 '22 07:09 loevgaard

Shopify handles 'cost' as part of 'inventory', which is separate from 'product' logic. Not all stores use their online shop to manage inventory, so it makes sense to have inventory be part of an optional module.

https://shopify.dev/api/admin-rest/2022-10/resources/inventoryitem https://shopify.dev/api/admin-rest/2022-10/resources/product

nikkuexe avatar Nov 23 '22 22:11 nikkuexe

@nikkuexe: I see your point, but Sylius already has inventory in the core, i.e. not as a plugin :)

loevgaard avatar Nov 28 '22 12:11 loevgaard

@loevgaard For the scope of the discussion on cost, this is more similar to "inventory management" which is a function of a fulfillment center, not the online storefront.

Shopify gives a good explanation of this logic here: https://shopify.dev/api/admin-rest/2022-10/resources/inventorylevel

A product sold on a Sylius store could be fulfilled from one or more locations, and the cost per unit may be different at different locations.

nikkuexe avatar Nov 30 '22 21:11 nikkuexe