I am trying to get the subscription information from the WordPress’s WooCommerce plugin, but I don’t want to load the crazy load of files that WP loads and slows down the server. What I currently use is as follows:
$subscription = false;
$result = WC_Subscriptions_Manager::get_users_subscriptions( $userID );
foreach ($result as $key => $value) {
if ($result[$key]["status"]=="active") $subscription = true;
}
But is there any way, will I be able to do it without including the following crazy code:
require('wp-load.php');
I just wanna connect to the DB and find out something. What I have now in WooCommerce entry for me is a big text chunk of:
a:1:{s:7:"609_222";a:11:{s:10:"product_id";s:3:"22";s:9:"order_key";s:19:"order_5396dcccd4049";s:8:"order_id";i:609;s:10:"start_date";s:19:"2014-06-10 10:37:51";s:11:"expiry_date";i:0;s:8:"end_date";i:0;s:6:"status";s:6:"active";s:17:"trial_expiry_date";i:0;s:15:"failed_payments";i:0;s:18:"completed_payments";a:1:{i:0;s:19:"2014-06-10 10:37:52";}s:16:"suspension_count";i:0;}}
I have no clue on how to get this piece of code working without using wp-load.php
. Any heads up?
Your data is serialize so
maybe_deserialize
andis_serialize
function should work, just copie them:Codex
EDIT :
Your serialize have an error here :
s:3:"22"
s => String
3 => length of 3
but you have just two char.
Change 3 by 2 then you can unserialize
(it’s maybe corrupt data on your database, try with other user to see if it’s ok )
Online deserializer to test:
http://www.unserialize.com/s/54d4be2e-bc4a-8208-93eb-00000a0c6243
Example query, edit for wherever woocommerce resides.