Skip to content

Add API abstraction layers around our custom tables #1900

@JustinSainton

Description

@JustinSainton

Over the last few years, we've done a great job with this for a lot of our tables. WPSC_Purchase_Log, WPSC_Checkout_Form, WPSC_Checkout_Form_Data to name a few.

There are still a few tables where we don't have any helpful APIs wrapped around them. Having these abstraction layers helps us lay a unit-testable foundation for the potential of ever moving to a different database layer for these APIs, or a custom post type, or a RESTful response rather than a database layer. Lots of potential and improvements come with a properly abstracted data layer.

Looking through the current custom tables we have, we don't have abstractions for the following tables:

  • WPSC_TABLE_ALSO_BOUGHT (Note: Will likely not change this, per Deprecate 'Also Bought' functionality and provide via plugin #107)
  • WPSC_TABLE_CART_CONTENTS (Necessity here might be debatable, as it is so tightly coupled to the WPSC_Purchase_Log table. Might be worth exploring, though, for the sake of decoupling and having setters/getters for adding to cart contents. We don't have a great way to add to an already purchased cart. This could provide that.)
  • WPSC_TABLE_META - (So...we sort of have something here, but it's bananas. See Loads of DB queries to wpsc_get_meta() for country data #1894)
  • WPSC_DOWNLOAD_STATUS - Definitely need this. This is actually the table that prompted the ticket.
  • WPSC_TABLE_PRODUCT_RATING - Same as ALSO_BOUGHT

Custom tables we add that do have APIs (and the related classes):

  • Cart Item, Purchase and Visitor Meta ( wpsc_(crud)_*_meta() )
  • WPSC_TABLE_PURCHASE_LOGS - WPSC_Purchase_Log
  • WPSC_TABLE_CLAIMED_STOCK - WPSC_Claimed_Stock
  • WPSC_TABLE_COUPON_CODES - WPSC_Coupon
  • WPSC_TABLE_SUBMITTED_FORM_DATA - WPSC_Checkout_Form_Data
  • WPSC_TABLE_REGION_TAX WPSC_Countries/WPSC_Region
  • WPSC_TABLE_CURRENCY_LIST - WPSC_Country / WPSC_Countries
  • WPSC_TABLE_CHECKOUT_FORMS - WPSC_Checkout_Form

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions