How to add date range in woocommerce with code

I just figure out how to do it with a bit of reverse engineering, hopefuly this helps someone : $availability = array(); $availability[0][‘type’] = ‘time:range’; $availability[0][‘bookable’] = ‘yes’; //Default priority $availability[0][‘priority’] = 10; //case ‘time:range’ $availability[0][‘from’] = wc_booking_sanitize_time( $hours ); $availability[0][‘to’] = wc_booking_sanitize_time( $hours ); $availability[0][‘from_date’] = wc_clean( $date ); $availability[0][‘to_date’] = wc_clean( $date ); … Read more

How to access custom order item meta data from a meta key in WooCommerce?

There is at least 2 ways to get custom order item meta data from a defined meta key: 1) Since WooCommerce 3 – Using WC_Data method get_meta() 2) The older way – Using wc_get_order_item_meta() WooCommerce function So your hooked function bs_order_lead_time_data() code will be: add_action( ‘woocommerce_my_account_my_orders_column_order-lead-time’, ‘bs_order_lead_time_data’ ); function bs_order_lead_time_data( $order ) { foreach ( … Read more

Filter hook before create order WooCommerce

Stumbled on this looking for the same thing which I’ve now figured out (Woocommerce 3.x)… add_filter( ‘woocommerce_checkout_create_order’, ‘mbm_alter_shipping’, 10, 1 ); function mbm_alter_shipping ($order) { if ($something == $condition) { $address = array( ‘first_name’ => ‘Martin’, ‘last_name’ => ‘Stevens’, ‘company’ => ‘MBM Studio’, ’email’ => ‘[email protected]’, ‘phone’ => ‘777-777-777-777’, ‘address_1′ => ’99 Arcadia Avenue’, ‘address_2’ … Read more

Edit tag cloud widget number

Add the following to your theme’s function.php. Default values are shown below, except changing ‘number’ from 45 to 15. Only the changed values need to be included, so you can either leave the default values or remove/comment out those lines. For WordPress Tag Cloud widget: function custom_tag_cloud_widget() { $args = array( ‘smallest’ => 8, ‘largest’ … Read more

Woocommerce get selected shipping zone id for the current user

The problem is that WC_Cart get_shipping_packages() method gives an array of shipping packages and the function wc_get_shipping_zone( $package ) expect to have as argument a unique package. So you need to get only one package, using for example php reset() function like: // Get cart shipping packages $shipping_packages = WC()->cart->get_shipping_packages(); // Get the WC_Shipping_Zones instance … Read more

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