This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'rest_api_init', function () { | |
function set_custom_sorting( $response ) { | |
//var_dump([rand()]); | |
$response->data['custom_order'] = (int) get_term_meta($response->data['id'], 'order', true); | |
return $response; | |
} | |
add_filter( 'woocommerce_rest_prepare_product_attribute_term', 'set_custom_sorting', 10, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Link example: https://mywebsite.com/wp-json (because we have woo, acf etc. that deploy their unique endpoints | |
function getWooCategories(string $link, string $consumer_key, string $consumer_secret) | |
{ | |
$curl = curl_init(); | |
curl_setopt_array($curl, [ | |
CURLOPT_URL => $link . '/wc/v3/products/categories?per_page=100&consumer_key=' . $consumer_key . '&consumer_secret=' . $consumer_secret, | |
CURLOPT_RETURNTRANSFER => true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$xml = simplexml_load_file('arxeio1.xml'); | |
$filters = $xml->xpath('products/product/filter'); | |
foreach($filters as $filter) { | |
$feature_name = trim($filter->filter_name); | |
if ($feature_name == "ΙΣΧΥΣ/WATT") { | |
// Do something | |
echo "1<br />"; | |
} elseif ($feature_name == "LUMEN") { |