woocommerce

  • WooCommerce 3.0 deprecated direct property access

    Reading $product->id or $order->billing_email has worked since the plugin existed, because they were public properties on an object wrapping a post. 3.0 makes them private with a magic…

  • The data store is where custom tables become possible

    Products have always been posts, which is why a catalogue of any size ends up fighting wp_postmeta. The CRUD layer puts a data store between the object and…

  • Order item meta moved and the old table is a view

    3.0 moved order item data into its own tables and left the old access functions working, which means a query written against the old shape returns results and…

  • get_id() rather than ->id, and why it matters

    The getter looks like ceremony over a property and is the entire point of the release: with the read going through a method, where the value comes from…

  • wc_get_order returns different classes for different types

    An order, a refund and a subscription are all shop_order-ish posts and are not the same class, so code type-hinting WC_Order breaks the first time a refund arrives.…

  • CRUD objects load lazily, which changes your query count

    A 2.6 product was hydrated from the post and its meta in one pass. A 3.0 product reads what it is asked for, which is usually fewer queries…

  • WooCommerce 3.0 turned products into objects

    Every plugin reading _price from post meta is now reading a private field. The mechanical half, the half that is not, and the compatibility layer for code you…

  • WooCommerce sessions are not PHP sessions

    WooCommerce maintains its own session handler backed by a database table and a cookie, entirely separate from $_SESSION. Code that starts a PHP session to store something cart-related…

  • wc_get_orders is the query you should be using

    Orders are posts, so WP_Query works and every example on the internet uses it — with a post_type of shop_order, a meta query for the customer, and a…

  • Order status transitions have hooks of their own

    Hooking save_post to react to an order being paid works occasionally and misses every transition made from a payment gateway callback, the REST API or WP-CLI. The status…