if i try this:
$arr = [
'pa_yacht-dozvillya' => [
'name' => 'pa_yaht-dozvillya',
'value' => 'Акваскутер',
'is_visible' => 1,
'is_taxonomy' => 1,
],
];
update_post_meta(2194, '_product_attributes', $arr);
then this adds an attribute with no value
here
Related
I want to get product_id (from Website A ) Woocommerce APi and create a order in website B
If from Website A product_id =11 then create product_id= 1050 in website B
If product_id =121 then create product_id= 160 in website B
function create_order_from( $customer_id, $new_customer_data, $password_generated ) {
$live_ck = 'ck_blablabla';
$live_cs = 'cs_blablabla';
$live_url = 'https://www.website.com/wp-json/wc/v3/orders?consumer_key=' . $live_ck . '&consumer_secret=' . $live_cs;
$customer = new WC_Customer( $customer_id );
$body = array(
'status' => 'completed',
'meta_data' => array( array(
'key' => 'createdby',
'value' => 'website'
)),
'total' => 0,
'billing' => array(
'first_name' => $customer->get_billing_first_name(),
'email' => $customer->get_email(),
),
'line_items' => array( array(
'product_id' => 1050,
'quantity' => 1,
)),
);
$raw_response = wp_remote_post( $live_url,
array(
'headers' => array( 'Content-Type' => 'application/json' ),
'timeout' => 30,
'body' => json_encode( $body ),
)
);
}```
THank you for your help
When using metric totalAdRevenue (admanager 360 link in GA4) the metric 'totalAdRevenue' is not giving any results. In GA4 Query explorer i do get the right data.
My Code:
$ar = [
'property' => 'properties/' . $PROP_ID,
'dateRanges' => [
new DateRange([
'start_date' => $date->format("Y-m-d"),
'end_date' => $date->format("Y-m-d"),
]),
],
'dimensions' => [new Dimension(
[
'name' => 'sessionCampaignName'
]
),
],
'metrics' => [new Metric(
[
'name' => 'sessions'
]
), new Metric(
[
'name' => 'totalAdRevenue'
]
)
]
];
$response = $analytics->runReport($ar);
We need this output:
$filters = [
['property' => 'status.id', 'expression' => '!=', 'value' => 5],
['property' => 'status.id', 'expression' => '!=', 'value' => 1],
['property' => 'status.id', 'expression' => '!=', 'value' => 7],
];
and this way doesn't work:
foreach ($orderStatusItems as $orderStatusItem) {
$filters[] .= "['property' => 'status.id', 'expression' => '!=', 'value' => $orderStatusItem],";
}
here is the solution:
$orderFilters = [];
foreach ($orderStatusItems as $orderStatusItem) {
array_push($orderFilters, ['property' => 'status.id', 'expression' => '!=', 'value' => $orderStatusItem]);
}
I have 100 posts all have a meta_key named "isactive" whose value will either be "1" or "0"
I need to calculate the percentage of number of active posts(from 'isactive' metakey value) between any 2 dates
$args0 = array(
'date_query' => array(
array(
'after' => 'January 1st, 2013',
'before' => array(
'year' => 2013,
'month' => 2,
'day' => 28,
),
'inclusive' => true,
),
'meta_key' => 'isactive',
'meta_value' => 0
)
);
$count0 = new WP_Query( $args0 );
$args1 = array(
'date_query' => array(
array(
'after' => 'January 1st, 2013',
'before' => array(
'year' => 2013,
'month' => 2,
'day' => 28,
),
'inclusive' => true,
),
'meta_key' => 'isactive',
'meta_value' => 1
)
);
$count1 = new WP_Query( $args1 );
echo $percent = $count0/$count1;
Whether this type of query works ?
Else is there any better way to calculate percentage based on the meta key values between 2 dates?
I have "product" custom post type. It have 2 custom fields: price1, price2 (price of product)
I want to get all posts have price1 < price2 (compare 2 values)
How can i do that?
Here's a nice sample that should help you out:
$args = array(
'tax_query' => array(
'taxonomy' => 'custom_taxonomy_name',
array(
'key' => 'price',
'value' => array( 100, 200 ),
'compare' => 'BETWEEN',
'type' => 'numeric',
),
array(
'key' => 'description',
'value' => 'round',
'compare' => 'NOT LIKE'
)
)
);
$query = new WP_Query($args);