How to retrieve a value from a stdClass Object? - stdclass

I have this class object:
stdClass Object
(
[status] => success
[data] => stdClass Object
(
[network] => BTC
[available_balance] => 0.00001
[pending_received_balance] => 0.0
)
)
How to get the value of only [available_balance]?
NB: im using php

Related

Meta Query being igored in WP

I am attempting a meta query to get between two prices set as a meta field in my custom post.
However the _ccprop_prop_price query is being ignored. Its still giving results higher than 100000 , I can confirm the id of the meta field is _ccprop_prop_price. It is worth noting however that the field is a text field not a number field.
Am I missing something obvious? I even tried to break it down further by doing two arrays and using < and > instead.
Edit: Just another development, I notice = does in fact work which makes me wonder is it something to do with it being a text field.
Here is the resulting final $args
(
[post_type] => property
[orderby] => meta_value_num
[meta_key] => _ccprop_prop_price
[order] => ASC
[posts_per_page] => 30
[paged] => 1
[tax_query] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
)
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[key] => _ccprop_prop_price
[value] => Array
(
[0] => 0
[1] => 100000
)
[compare] => BETWEEN
[type] => NUMERIC
)
)
)
I found the issue, there were commas for some of the prices in that meta field and they were the ones appearing.

As I read (foreach php) this array stdClass

I have the following code which gives me a query generated , what I need it is to walk the array ( php foreach ) to query the data.
I tried to do with the classic foreach (php) but I foreach throws an error.
Thanks in advance...
Array (
[0] => stdClass Object
(
[_new] =>
[_attributes] => Array
(
[id] => 36
[nombre] => Diana
[estado] => 1
)
[_related] => Array
(
)
[_c] =>
[_pk] => 36
[_alias] => t
[_errors] => Array
(
)
[_validators] =>
[_scenario] => update
[_e] =>
[_m] =>
)
[1] => stdClass Object
(
[_new] =>
[_attributes] => Array
(
[id] => 1
[geoCode] => MAX
)
[_related] => Array
(
)
[_c] =>
[_pk] => 1
[_alias] => t
[_errors] => Array
(
)
[_validators] =>
[_scenario] => update
[_e] =>
[_m] =>
))
As I walk or convert to be read as ?
<?php foreach ($response as $value) {echo $value->nombre;} ?>

One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.'

I integrated Mangopay plugin into my wordpress site for crowdfunding
After configuring it and when i try to purchase using mangopay interface i got these errors.
exception 'MangoPay\ResponseException' with message 'Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.' in /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/restTool.inc:272
Stack trace:
#0 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/restTool.inc(126): MangoPay\RestTool->CheckResponseCode(Object(stdClass))
#1 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/restTool.inc(93): MangoPay\RestTool->RunRequest()
#2 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/apiBase.inc(157): MangoPay\RestTool->Request('/users/natural', 'POST', Array)
#3 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/apiUsers.inc(24): MangoPay\ApiBase->CreateObject('users_createnat...', Object(MangoPay\UserNatural))
#4 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/gateway/class-wm-fonctions-gateway.php(65): MangoPay\ApiUsers->Create(Object(MangoPay\UserNatural))
#5 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/gateway/class-wm-fonctions-gateway.php(43): WM_Fonction_Gateway::wm_create_mangopay_user(Object(WP_User))
#6 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/gateway/class-wm-woocommerce-gateway.php(104): WM_Fonction_Gateway::wm_get_mangopay_user(Object(WP_User))
#7 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(646): WM_Woocommerce_Gateway->process_payment(1804)
#8 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(369): WC_Checkout->process_checkout()
#9 [internal function]: WC_AJAX::checkout('')
#10 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-includes/plugin.php(496): call_user_func_array(Array, Array)
#11 /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-admin/admin-ajax.php(85): do_action('wp_ajax_woocomm...')
#12 {main}MangoPay\ResponseException Object
(
[_responseCodes:MangoPay\ResponseException:private] => Array
(
[200] => OK
[206] => PartialContent
[400] => Bad request
[401] => Unauthorized
[403] => Prohibition to use the method
[404] => Not found
[405] => Method not allowed
[413] => Request entity too large
[422] => Unprocessable entity
[500] => Internal server error
[501] => Not implemented
)
[_errorInfo:MangoPay\ResponseException:private] => MangoPay\Error Object
(
[Message] => One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.
[Errors] => stdClass Object
(
[AuthorId] => The AuthorId field is required.
)
)
[RequestUrl] => https://api.sandbox.mangopay.com/v2/rota90/payins/card/web/
[message:protected] => Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.
[string:Exception:private] =>
[code:protected] => 400
[file:protected] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/restTool.inc
[line:protected] => 272
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/restTool.inc
[line] => 126
[function] => CheckResponseCode
[class] => MangoPay\RestTool
[type] => ->
[args] => Array
(
[0] => stdClass Object
(
[Message] => One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.
[Type] => param_error
[Id] => a3a12c22-1bc3-41ff-b92b-d923cd763e7f
[Date] => 1427279161
[errors] => stdClass Object
(
[AuthorId] => The AuthorId field is required.
)
)
)
)
[1] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/restTool.inc
[line] => 93
[function] => RunRequest
[class] => MangoPay\RestTool
[type] => ->
[args] => Array
(
)
)
[2] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/apiBase.inc
[line] => 157
[function] => Request
[class] => MangoPay\RestTool
[type] => ->
[args] => Array
(
[0] => /payins/card/web/
[1] => POST
[2] => Array
(
[CreditedWalletId] => 6183033
[CardType] => CB_VISA_MASTERCARD
[ReturnURL] => http://itsaboutmyafrica.com/checkout/order-received/1804?key=wc_order_551277ae9f920
[Culture] => TN
[SecureMode] => DEFAULT
[DebitedFunds] => Array
(
[Currency] => EUR
[Amount] => 46000
)
[Fees] => Array
(
[Currency] => EUR
[Amount] => 0
)
[Tag] => 1804
)
)
)
[3] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/mangoPaySDK/tools/apiPayIns.inc
[line] => 17
[function] => CreateObject
[class] => MangoPay\ApiBase
[type] => ->
[args] => Array
(
[0] => payins_card-web_create
[1] => MangoPay\PayIn Object
(
[CreditedWalletId] => 6183033
[PaymentType] => CARD
[PaymentDetails] => MangoPay\PayInPaymentDetailsCard Object
(
[CardType] => CB_VISA_MASTERCARD
[CardId] =>
)
[ExecutionType] => WEB
[ExecutionDetails] => MangoPay\PayInExecutionDetailsWeb Object
(
[RedirectURL] =>
[ReturnURL] => http://itsaboutmyafrica.com/checkout/order-received/1804?key=wc_order_551277ae9f920
[TemplateURL] =>
[Culture] => TN
[SecureMode] => DEFAULT
)
[AuthorId] =>
[CreditedUserId] =>
[DebitedFunds] => Array
(
[Currency] => EUR
[Amount] => 46000
)
[CreditedFunds] =>
[Fees] => Array
(
[Currency] => EUR
[Amount] => 0
)
[Status] =>
[ResultCode] =>
[ResultMessage] =>
[ExecutionDate] =>
[Type] =>
[Nature] =>
[Id] =>
[Tag] => 1804
[CreationDate] =>
)
[2] => \MangoPay\PayIn
)
)
[4] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/gateway/class-wm-fonctions-gateway.php
[line] => 129
[function] => Create
[class] => MangoPay\ApiPayIns
[type] => ->
[args] => Array
(
[0] => MangoPay\PayIn Object
(
[CreditedWalletId] => 6183033
[PaymentType] => CARD
[PaymentDetails] => MangoPay\PayInPaymentDetailsCard Object
(
[CardType] => CB_VISA_MASTERCARD
[CardId] =>
)
[ExecutionType] => WEB
[ExecutionDetails] => MangoPay\PayInExecutionDetailsWeb Object
(
[RedirectURL] =>
[ReturnURL] => http://itsaboutmyafrica.com/checkout/order-received/1804?key=wc_order_551277ae9f920
[TemplateURL] =>
[Culture] => TN
[SecureMode] => DEFAULT
)
[AuthorId] =>
[CreditedUserId] =>
[DebitedFunds] => Array
(
[Currency] => EUR
[Amount] => 46000
)
[CreditedFunds] =>
[Fees] => Array
(
[Currency] => EUR
[Amount] => 0
)
[Status] =>
[ResultCode] =>
[ResultMessage] =>
[ExecutionDate] =>
[Type] =>
[Nature] =>
[Id] =>
[Tag] => 1804
[CreationDate] =>
)
)
)
[5] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/wordpressmangopay/includes/gateway/class-wm-woocommerce-gateway.php
[line] => 152
[function] => wm_create_payin
[class] => WM_Fonction_Gateway
[type] => ::
[args] => Array
(
[0] =>
[1] => http://itsaboutmyafrica.com/checkout/order-received/1804?key=wc_order_551277ae9f920
[2] => 1804
)
)
[6] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/woocommerce/includes/class-wc-checkout.php
[line] => 646
[function] => process_payment
[class] => WM_Woocommerce_Gateway
[type] => ->
[args] => Array
(
[0] => 1804
)
)
[7] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-content/plugins/woocommerce/includes/class-wc-ajax.php
[line] => 369
[function] => process_checkout
[class] => WC_Checkout
[type] => ->
[args] => Array
(
)
)
[8] => Array
(
[function] => checkout
[class] => WC_AJAX
[type] => ::
[args] => Array
(
[0] =>
)
)
[9] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-includes/plugin.php
[line] => 496
[function] => call_user_func_array
[args] => Array
(
[0] => Array
(
[0] => WC_AJAX
[1] => checkout
)
[1] => Array
(
[0] =>
)
)
)
[10] => Array
(
[file] => /homepages/17/d555245609/htdocs/Itsaboutmyafrica/wp-admin/admin-ajax.php
[line] => 85
[function] => do_action
[args] => Array
(
[0] => wp_ajax_woocommerce_checkout
)
)
)
[previous:Exception:private] =>
[_code] => 400
)
I used mangopay wordpress plugin 1.0.5 with woocommerce 2.3 and ignitiondeck-crowdfunding
Could you please help me get rid from these errors?
Thanks in advance.
I was having this issue and it turns out that Address is missing. I added
$user->Address = null;
to solve this.

Single Meta key with multiple values not working in searching

I have search query where i am using single meta_key with multiple values but its not working . here is the meta query .
[meta_query] => Array
(
[0] => Array
(
[key] => _vital_lighting_color
[value] => Array
(
[0] => red
[1] => green
[2] => blue
)
[type] => char
[compare] => IN
)
)
but its not fetching record i don't what's happening can you please check it .
Thanks
Using proper php syntax would help :
$query_args = array(
'meta_query' => array(
'key' => '_vital_lighting_color' ,
'value' => array
('red' , 'green' ,'blue' ) ,
'compare' => 'IN'
)
) ;
I removed type, because "char' is the default value
If it does not work, then run a query on the database directly to check you have posts

How to get the values of select options in Drupal using form alter?

I am trying to cycle through a select list on an exposed form filter and hide terms I don't need.
With my select box being called ttd-tid I tried:
foreach ($form['ttd_tid']['#options'] as $tid => $term){
if (in_array($tid,$child_terms_tids)){
//leave it
}else{
//remove it
unset($form['ttd_tid']['#options'][$tid]);
}
}
But $tid is not the option value. It seems to be the count.
I tried
foreach ($form['ttd_tid']['#options']['option'] as $tid => $term){
But that didn't work either.
Essentially, I need to compare the value of the option to an array and hide it. And I can't seem to get it to work since $tid seems to be yet another array.
My $form array looks like this
Array ( [#info] => Array ( [filter-field_things_to_do_tags_tid] => Array ( [operator] => field_things_to_do_tags_tid_op [value] => ttd_tid [label] => Things to Do Tags [description] => ) ) [ttd_tid] => Array ( [#type] => select [#options] => Array ( [All] => - Any - [0] => stdClass Object ( [option] => Array ( [86] => Amusement Parks ) ) [1] => stdClass Object ( [option] => Array ( [63] => -Theme Parks ) ) [2] => stdClass Object ( [option] => Array ( [611] => -Water Parks ) ) [3] => stdClass Object ( [option] => Array ( [612] => Arts, Culture & History ) ) [4] => stdClass Object ( [option] => Array ( [1] => -Architecture & Landmarks ) ) [5] => stdClass Object ( [option] => Array ( [30] => -Galleries ) ) [6] => stdClass Object ( [option] => Array ( [32] => -History & Culture ) ) [7] => stdClass Object ( [option] => Array ( [83] => -Museums ) ) [8] => , etc, etc
Try
foreach ($form['ttd_tid']['und']['#options'] as $tid => $term){
If that dont work using the following within you form alter it will print out the array to /admin/reports/dblog when you load the page
watchdog('$form', '<pre>'.print_r($form, true).'</pre>');

Resources