Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for additional actions for function wc_update_product_stock() #339

Closed
magenta-cuda opened this issue Sep 18, 2021 · 4 comments
Closed
Labels
enhancement New feature or request Needs PR Issue to be fixed. Needs a PR.

Comments

@magenta-cuda
Copy link

magenta-cuda commented Sep 18, 2021

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
Copy link

ghost commented Sep 18, 2021

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?

@ghost ghost added the enhancement New feature or request label Sep 18, 2021
@bahiirwa
Copy link
Collaborator

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?

@bahiirwa bahiirwa added the Needs PR Issue to be fixed. Needs a PR. label Sep 19, 2021
@magenta-cuda
Copy link
Author

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
Copy link

ghost commented Sep 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Needs PR Issue to be fixed. Needs a PR.
Projects
None yet
Development

No branches or pull requests

2 participants