woocommerce_get_price filter hook not working for product variation price

I had to add the filter hook for product variation as well. add_filter( ‘woocommerce_product_get_price’, ‘pr_reseller_price’, 10, 2 ); add_filter( ‘woocommerce_product_variation_get_price’, ‘pr_reseller_price’, 10, 2 ); add_filter( ‘woocommerce_product_get_regular_price’, ‘pr_reseller_price’, 10, 2 ); add_filter( ‘woocommerce_product_get_sale_price’, ‘pr_reseller_price’, 10, 2 );

woocommerce product custom field

You should ad the custom field to product API response, try this (untested) add_filter( ‘woocommerce_rest_prepare_product’, ‘custom_products_api_data’, 90, 2 ); function custom_products_api_data( $response, $post ) { // retrieve a custom field and add it to API response $response->data[‘purchasing_cost’] = get_post_meta( $post->ID, ‘purchasing_cost’, true ); return $response; }

How to disable users from editing billing address in WooCommerce checkout?

Okay I found a solution after Slack conversation. It is possible to remove the fields from checkout by unsetting them in woocommerce_billing_fields hook and then re-adding the values again to the order from users profile with woocommerce_checkout_posted_data hook. add_filter( ‘woocommerce_checkout_posted_data’, ‘fill_order_billing_details’ ); function fill_order_billing_details( $data ) { $customer_id = get_current_user_id(); $data[‘billing_first_name’] = get_user_meta( $customer_id, ‘billing_first_name’, … Read more

Calling calculate_shipping() with ajax in woocommerce

I also have the same issue when I created a shipping method and what I did is on my function for the ajax call I add something just to have an update on the cart: global $woocommerce; $packages = $woocommerce->cart->get_shipping_packages(); foreach( $packages as $package_key => $package ) { $session_key = ‘shipping_for_package_’.$package_key; $stored_rates = WC()->session->__unset( $session_key … Read more

Woocommerce – disable «place order» until user checks Privacy Policy

I think you should jQuery to enable and disable the checkout button. Please try this script. Put this script in the footer.php. jQuery(window).on(‘load’,function(){ setTimeout(function(){ jQuery(‘#payment #place_order’).attr(“disabled”,”disabled”); console.log(‘Hello’); },1000); }); jQuery(document).on(‘change’,’#privacy_policy_field #privacy_policy’,function() { var ischecked= jQuery(this).is(‘:checked’); if(!ischecked){ jQuery(‘#payment #place_order’).attr(“disabled”,”disabled”); console.log(‘unchecked’); }else{ jQuery(‘#payment #place_order’).removeAttr(“disabled”); console.log(‘checked’); } }); Note: This is tested script for your code.

Getting categories id for all products in cart

Use $cart_item[‘data’]->get_category_ids() to retrieve the category IDs: $category_ids = $cart_item[‘data’]->get_category_ids(); // array The category_ids you see is not a direct item in the $cart_item array: var_dump( $cart_item[‘category_ids’] ); // null and PHP throws a notice It’s an item in a protected property of the product data ($cart_item[‘data’]) which is an object, or a class instance … Read more

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