ClassicPress / classic-commerce

A simple but powerful e-commerce platform built for ClassicPress. Forked from WooCommerce and compatible with many Woo extensions.
https://classiccommerce.cc/
GNU General Public License v3.0
54 stars 15 forks source link

Request for additional actions for function wc_update_product_stock() #339

Closed magenta-cuda closed 3 years ago

magenta-cuda commented 3 years ago

WooCommerce has added two more actions - 'woocommerce_variation_before_set_stock' and 'woocommerce_product_before_set_stock' - to function wc_update_product_stock() in file wc-stock-functions.php. ` function wc_update_product_stock( $product, $stock_quantity = null, $operation = 'set', $updating = false ) {

    ...
        $data_store            = WC_Data_Store::load( 'product' );

        // Fire actions to let 3rd parties know the stock is about to be changed.
        if ( $product_with_stock->is_type( 'variation' ) ) {
            do_action( 'woocommerce_variation_before_set_stock', $product_with_stock );
        } else {
            do_action( 'woocommerce_product_before_set_stock', $product_with_stock );
        }

        // Update the database.
        $new_stock = $data_store->update_product_stock( $product_id_with_stock, $stock_quantity, $operation );
   ...
}

` These actions would be extremely useful to my plugin and I think useful to other 3rd party plugins as well.

ghost commented 3 years ago

This is a small change to 2 files as outlined here: https://github.com/woocommerce/woocommerce/pull/27558/files

It was introduced in WC 4.9.

Enhancement - add product and variation before_set_stock action hooks to allow 3rd party plugins to snapshot a product’s stock quantity before it is updated.

@bahiirwa and @nylen - any opinions on this?

bahiirwa commented 3 years ago

This is a simple change that would be good for CC. Thanks @magenta-cuda @simplycomputing for highlighting this.

Would you like to make a PR for this?

magenta-cuda commented 3 years ago

No, my feeling is ClassicCommerce is not a viable product and I am porting my plugin which currently only works with ClassicCommerce to WooCommerce. While porting I am finding fixes that were made to WooCommerce after the fork of ClassicCommerce. As it takes only a small effort to submit these as issues I am willing to do this. However, a pull requests means coding and testing - this would require a significant investment of resources which I am not willing to do for a non-viable product. Anyway, my history with the stakeholders of ClassicPress and ClassicCommerce has not been very good - I have submitted multiple issues and pull requests and all of them have gone nowhere. So, you will understand my reluctance to do more.

I feel the stake holders of CP and CC are not willing to further invest the resources to further develop CP and CC into good products. I apologize if this seems harsh but it is honestly the impression I have. If this is not the case then I think you need to do something differently to better reflect the resources you are committing to further develop CP and CC. Is your user base growing or shrinking? If it is not growing them maybe you need to do something different.

Having said that, I really would like to see ClassicPress and ClassicCommerce succeed because:

  1. Selfishly, porting my plugin to WooCommerce is quite difficult.

  2. I don't like the direction WordPress and WooCommerce is taking. WP and WC seems to be focused on being a better alternative to WIX as a website builder instead of becoming a better CMS. Gutenberg is wonderful technology as it makes it possible for a non-technical website designer to build a customizable website. But, Gutenberg is of no value to me. In the kind of complex website that I want to build, I can build a much better website by writing code to generate exactly the HTML that I want instead of configuring a website builder to generate approximately the HTML that I want. In my opinion, CP and CC is ideally positioned for this market segment - complex websites that cannot be accurately built with website builders like Gutenberg or WIX.

Regards, mc

ghost commented 3 years ago

You talk about "the stakeholders of ClassicPress and ClassicCommerce" as if there is a team of developers out there somewhere dedicated to doing the work. This is a community project, so the stakeholders are actually you and me.

Anyway, thanks for the input. The issue has been noted.