woocommerce show cities state as dropdown list

I achieved something similar using the woocommerce_default_address_fields filter You can do something in the lines of this to create your new cities: // UPDATE CHECKOUT CITY FIELD add_filter( ‘woocommerce_default_address_fields’ , ‘custom_override_default_address_fields’ ); // Our hooked in function – $address_fields is passed via the filter! function custom_override_default_address_fields( $address_fields ) { // Billing City $address_fields[‘city’][‘type’] = ‘select’; … Read more

unable to get product by category only getting product added lastly

Try this code. <?php if(isset($_POST[‘step_03’])) { $que_01 = $_POST[‘que_01’]; $que_02 = $_POST[‘que_02’]; $que_03 = $_POST[‘que_03’]; $subcat = array(“$que_01”, “$que_02”, “$que_03”); $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ‘product_tag’ => $que_01 ); } else { if(isset($_POST[‘cat’])) { $tags = $_POST[‘cat’]; } $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ‘product_category’ => $tags ); … Read more

Translate text for empty product

In your function ‘translate_text’ variable $product is not initialized, so the price is always empty. You need to provide the $product for use inside the function, consider the function, it should be global. Try modifying function: function translate_text($translated) { global $product; if ($product && empty($product->price)){ $translated = str_ireplace(‘Weiterlesen’, ‘Contact US’, $translated); } return $translated; } … Read more

how to add a page to a plugin?

You can use the activation hook and call function wp_insert_post() class MyPlugin { static function install() { $my_post = [ ‘post_title’ => ‘My page title’, ‘post_content’ => ‘My page content’, ‘post_status’ => ‘publish’, ‘post_author’ => 1, // Set author id here ‘post_type’ => ‘page’, ]; wp_insert_post( $my_post ); } } register_activation_hook( __FILE__, [ ‘MyPlugin’, ‘install’ … Read more

How to display India country first in country selection drop down list in WordPress

You can use a code in your functions.php file to select a default country in checkout page drop-down. /** * Change the default state and country on the checkout page */ add_filter( ‘default_checkout_billing_country’, ‘change_default_checkout_country’ ); function change_default_checkout_country() { return ‘IN’; // country code } Please let me know if code works.