Unable to enocde the result of wc_get_products

Try: $products_posts_arr = (array) $products_posts; echo json_encode( $products_posts_arr ); OR function object_to_array($data) { if (is_array($data) || is_object($data)) { $result = array(); foreach ($data as $key => $value) { $result[$key] = object_to_array($value); } return $result; } return $data; } $products_posts_arr = object_to_array( $products_posts ); echo json_encode( $products_posts_arr ); Encode array not object, wc_get_products will return object.

wp plugin not working after website live

Please check the following You have checked the URL of your WordPress installation You have checked that your webhosting is compatible with uploading (file permissions, user rights) You re-saved the permalinks (to make sure that URLs are used correctly) Edit: This little amount of information gives us little space to work with. Also, please check … Read more

How can I server scaled images?

You can follow this step to set thumbnail woocommerce size Go to Appearance > Customize. Then go to WooCommerce > Product Images. Then go to WooCommerce > Product Images Write your desired width in “Thumbnail width” field. You can set the height of the images in “Thumbnail Cropping” Click on “Publish” let me know the … Read more

Create an unique ID number after submit form

in order to do this use AUTO_INCREMENT PRIMARY KEY while you define your table. Your table should be something like this: CREATE TABLE `order` ( `order_id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, `user_group_id` INT(11) UNSIGNED NOT NULL, `status` BIT, `meta` VARCHAR ( 255 ), `value` TEXT, `update_time` TIMESTAMP )DEFAULT CHARSET = utf8; remember that you could … Read more

Stuck on Database Update Required after downgrading to 4.9.9 from backup

You are facing the issue due to the different database versions. Please, follow this steps to fix the issue: Head to /wp-include/ folder. Open the version.php file. Find the value for $wp_db_version. Open your database. Find wp_options. Use the following line to identify the value of db_version: SELECT option_value FROM yourdatabase.wp_options WHERE option_name=”db_version”; The values … Read more

Add HTML before a specific div?

Seems like jQuery is best for this case. Mainly answering for myself in case I’ll need it again in the future: <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <script> $(document).ready(function(){ $(“#this_comes_before”).insertBefore(“#wc_checkout_add_ons”); }); </script> </head> <body> <div id=”wc_checkout_add_ons”>stuff</div> <div id=”this_comes_before”>something</div> </body> Edit for future me: Use this instead you lazy asshole… add_action( ‘woocommerce_checkout_after_customer_details’, ‘test99’ ); function test99() { echo “your … Read more