How to set value/term of a Woocommerce attribute text field in admin panel?

I am assuming the ID of that text filed, is url-field here is the JS code $(“#url-field”).keyup(function(event) { var url_val=$(“#url-field”).val(); $.ajax({ type:”POST”, url: ajaxurl, data: { action:’use_someprefix_update_url’, search_string:url_val, namefiled : namehere, postid : postidhereYouCangetItIHope }, success:function(data){ alert(“Success, you can remove me 🙂 “); } }); }); Here comes PHP, put this in functions.php function use_someprefix_update_url(){ … Read more

Custom Woocommerce image size [closed]

There’s a few options you can choose from whenever changing image sizes. Switching out the actual default WooCommerce images is more difficult than a normal WordPress install as they are ingrained with the plugin. Modify Related Product Image Sizes: I’ve tested this and it seems to work only on related products ( though I’m sure … Read more

Approach for saving a product attribute values with a custom UI in a woocommerce+dokan set up [closed]

Actually, this ended up being straight forward. Displaying the drop down I used this line to get the list of terms for my pa_condition taxonomy: $attr_condition = get_terms( array( ‘taxonomy’ => ‘pa_condition’, //empty string(”), false, 0 don’t work, and return empty array ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => false, //can be 1, ‘1’ … Read more

Retrieve products with specific attribute and in category – woocommerce

You should use wc_get_products and a custom filter for adding your specific query. Example I want to find products containing a specific attribute value “table-filter”. $args = array( ‘table-filter’ => array(1,2,3) ); $products = wc_get_products($args); Than I have a filter for this: add_filter(‘woocommerce_product_data_store_cpt_get_products_query’, ‘my_handle_custom_query_var’, 10, 2); function my_handle_custom_query_var($query, $query_vars) { if (!empty($query_vars[‘table-filter’])) { $query[‘tax_query’][] = … Read more

Add Products to user’s ID Woocommerce

/* Add to cart product api */ add_action( ‘rest_api_init’, function () { register_rest_route( ‘wp/v2’, ‘add_to_cart_product’, array( ‘methods’ => array(‘GET’,’POST’), ‘callback’ => ‘add_to_cart_product’, ) ); } ); function add_to_cart_product(){ //wp_set_current_user($_POST[‘user_id’]); /*wp_set_auth_cookie($_POST[‘user_id’]);*/ /* Required Parameters $_POST[‘user_id’] $_POST[‘product_id’] */ global $woocommerce,$wpdb; $array = $wpdb->get_results(“select meta_value from “.$wpdb->prefix.”usermeta where meta_key=’_woocommerce_persistent_cart_1′ and user_id = “.$_POST[‘user_id’]); $data =$array[0]->meta_value; $cart_data=unserialize($data); $flag = … Read more

Redirect woocommerce single-product page

As per this post (https://stackoverflow.com/questions/43621049/woocommerce-multiple-single-product-templates-using-single-product-php-to-redire) I would update your code to look like this: function so_43621049_template_include( $template ) { if ( is_singular(‘product’) ) { $template = plugin_dir_path( __FILE__ ).’woocommerce/single-product.php’; } return $template; } add_filter( ‘template_include’, ‘so_43621049_template_include’, 20 ); I haven’t had a chance to test this but I believe it will work.

Automatically check the option “Enable stock management at product level” on product creation

To set default values of a new post, you can try this code : $postType = “product”; add_action(“save_post_” . $postType, function ($post_ID, \WP_Post $post, $update) { if (!$update) { // default values for new products update_post_meta($post->ID, “_manage_stock”, “yes”); update_post_meta($post->ID, “_stock”, 1); return; } // here, operations for updated products }, 10, 3);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)