kilbot / WooCommerce-POS

:bangbang: All development now at https://github.com/wcpos.
http://wcpos.com
GNU General Public License v3.0
353 stars 125 forks source link

Cost of Goods #76

Closed scopefragger closed 8 years ago

scopefragger commented 9 years ago

Ok not so much an issue, More of a cross plugin integration issue

Our Client uses COG plugin http://www.woothemes.com/products/woocommerce-cost-of-goods/ We have patched POS to work with this plugin ( our version can be found here : https://bitbucket.org/scopefragger/pos/commits/799308ba69a62a7d7dd18ee949cdd28fe113bf10#chg-public/includes/class-pos-checkout.php ) Client is happy to share the code.

The amends are line 316, ish;

Were either looking for a way for the client to keep updating there POS plugin without losing this patch every time !

kilbot commented 9 years ago

Hi Mark,

The new version of the plugin uses the WC REST API v2 to create orders - this functionality didn't exist at the 0.3 release so I had to create the orders in the POS code.

Given that the orders are created in WC proper, all third party hooks should work okay.

If there is any problems after the next update please leave a comment below and I'll contact the COG plugin authors to find out what's going wrong.

scopefragger commented 9 years ago

Fantastic client will be happy! Ill keep an eye out with the client over the next patch Cheers for the fast reply.

kilbot commented 9 years ago

I'm closing this issue as it should have been fixed in 0.4. Let me know if it's still an issue and I'll reopen.

igadgetsmty commented 9 years ago

Hi, this issue continue i just updates to 0.4.1 and cost of goods not working

kilbot commented 9 years ago

@maxrice can you take a look at this?

It seems that Cost of Goods is using the class-wc-checkout.php hooks rather than the abstracted hooks, which means that it does not support orders created using the REST API.

Could you look at changing woocommerce_add_order_item_meta to woocommerce_order_add_product.

There's no common action for woocommerce_checkout_update_order_meta but you could use woocommerce_api_create_order to run the order_meta method for API orders.

Additionally the REST API allows editing of orders so you would need to update cog meta with woocommerce_order_edit_product and woocommerce_api_edit_order.

maxrice commented 9 years ago

@kilbot - thanks for digging into that :smile: I believe we were using those older hooks to support WC 2.1, which we'll be dropping support for as part of our compatibility updates for WC 2.4. We'll fix this in an update later this month.

kilbot commented 9 years ago

Ah yes .. backwards compatibility, that's something I keep forgetting about (being a plugin newbie).

I realise the links are probably not necessary seeing as though you created those hooks, but I thought I'd include them for anyone following along :smile:

igadgetsmty commented 9 years ago

Hi, do you have a relase date or a temporal solution for this? i will like to use new versión and dont go back to older versions

maxrice commented 9 years ago

This should be resolved in the upcoming v1.8.1 version of Cost of Goods :)

kilbot commented 9 years ago

great! :+1:

rfink commented 8 years ago

Does cost of goods value come back through the REST API?

kilbot commented 8 years ago

@rfink just wondering if this is regarding the POS? If so, the default POS templates would need to be customised to display the Cost of Goods.

If you have the POS installed you can view the raw product JSON by going to http://<your-domain>/wc-api/v3/products/?pos=1, this will show you which product attributes are available.

rfink commented 8 years ago

I may have actually asked this in the wrong place, I'm not sure where to ask. I'm looking to ask this question to whomever maintains the default WooCommerce REST API.

kilbot commented 8 years ago

@rfink The default product JSON is shown on the WC REST API documentation. Obviously the default properties will not include data from third party plugins.

Extra product data can added by the third party plugin or by website owners to suit their requirements. Personally, I think it should be up to the individual users to customise the product JSON to fit their requirements. The API should be as fast as possible and this could become an issue if many plugins add data to the output.

Adding custom data to the product JSON is fairly easy using the woocommerce_api_product_response filter.

A function to add cost of goods data will look something like:

function my_custom_product_response( $product_data, $product ){
  $product_data['cog'] = WC_COG_Product::get_cost( $product );
  return $product_data;
}
add_filter( 'woocommerce_api_product_response', 'my_custom_product_response', 10, 2 );

The above is untested but should get you close.

gepd commented 8 years ago

Hi, I don't know where to post this issue, as I don't know who the problem is.

Some weeks ago, I guess before the last 2 or 3 updates, this plugin was working fine to me. If I looked in the "orders" tab, I could see the reports of my sales, but now I only can see the report in the "profit" tab. When a client purchase something in the web, it's showing in the "order" tab, but when I use the pos, it doesn't appear. I don't know if it's possible to fix.

kilbot commented 8 years ago

Hi @gepd, this bug is already on the known bugs page for 0.4.5, it will be fixed in the next version of WooCommerce POS.

gepd commented 8 years ago

Thanks for your answer @kilbot I'll wait until the next version.