Git Product home page Git Product logo

Comments (8)

claudiosanches avatar claudiosanches commented on June 3, 2024 1

@callumstrubi we should write a blog post about REST API v3 in the next weeks. About your hook should still work, but probably you should stop using it in v3.

from wc-api-dev.

callumstrubi avatar callumstrubi commented on June 3, 2024

This is achievable trivially with the hook:

add_filter("woocommerce_rest_pre_insert_product_object", function($product, $request, $creating){
	if($request['date'] || $request['date_gmt']){
		$date = new \DateTime(($request['date_gmt'] ? $request['date_gmt'] : $request['date']), new \DateTimeZone('UTC'));
		$product->set_date_created($date->format('U'));
	}
	return $product;
}, 10, 3);

from wc-api-dev.

claudiosanches avatar claudiosanches commented on June 3, 2024

Solved in woocommerce/woocommerce#21117

from wc-api-dev.

callumstrubi avatar callumstrubi commented on June 3, 2024

Ah excellent, didn't see this in the release notes for 3.5 - do we expect this to be compatible with my hook, or do i need to do testing?

from wc-api-dev.

callumstrubi avatar callumstrubi commented on June 3, 2024

API v3 will come with a new endpoint though right? So we can plan migration effectively - thank you for the update and hard work in a v3 (WP limitations are constraining v2 too much).

from wc-api-dev.

claudiosanches avatar claudiosanches commented on June 3, 2024

Comes inside wc/v3 instead of wc/v2, so yes, you can do a migration to all new endpoints, test before and so on.

from wc-api-dev.

callumstrubi avatar callumstrubi commented on June 3, 2024

Sorry for comment spam - will wc-api-php be upgraded to support the v3 endpoint in line with it's release or will that come in the following months?

from wc-api-dev.

claudiosanches avatar claudiosanches commented on June 3, 2024

@callumstrubi already supports, just set the library to connect to v3.

Example:

require __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
    'http://example.com', 
    'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
    'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    [
        'wp_api' => true,
        'version' => 'wc/v3',
    ]
);

from wc-api-dev.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.