Skip to content

badasswp/create-product-on-image-upload

Repository files navigation

create-product-on-image-upload

Create WooCommerce products automatically by uploading images.

cpoiu-mini

Download

Download from WordPress plugin repository.

You can also get the latest version from any of our release tags.

Why Create Product On Image Upload?

This plugin makes it easy to create WooCommerce products by simply uploading the featured image of the product you intend to create. It will proceed to use the name of the image as the product name.

cpoiu.mp4

Hooks

cpoiu_post_args

This custom hook (filter) provides a way to customise the product's post args options that is used to create the product, like so:

add_filter( 'cpoiu_post_args', [ $this, 'update_post_args' ] );

public function update_post_args( $options ): array {
    $options[ 'post_status' ] = 'draft';

    return $options;
}

Parameters

  • options {array} By default this will be an associative array containing key, value options of a product's post args.

cpoiu_meta_args

This custom hook (filter) provides a way to customise the product's meta options that is used to update the product's meta values during creation time, like so:

add_filter( 'cpoiu_meta_args', [ $this, 'update_meta_args' ] );

public function update_meta_args( $options ): array {
    if ( empty( $options[ '_sale_price' ] ) ) {
        $options[ '_sale_price' ] = absint( $options[ '_regular_price' ] )
    }

    return $options;
}

Parameters

  • options {array} By default this will be an associative array containing key, value options of a product's meta.

Contribute

Contributions are welcome and will be fully credited. To contribute, please fork this repo and raise a PR (Pull Request) against the master branch.

Pre-requisites

You should have the following tools before proceeding to the next steps:

  • Composer
  • Yarn
  • Docker

To enable you start development, please run:

yarn start

This should spin up a local WP env instance for you to work with at:

http://create-product-on-image-upload.localhost:5698

You should now have a functioning local WP env to work with. To login to the wp-admin backend, please use admin for username & password for password.

Awesome! - Thanks for being interested in contributing your time and code to this project!