Woocommerce hook after creating order? [closed]

Try woocommerce_thankyou hook. This will trigger after recieving order successfully, no matter how user made payment. $hook_to = ‘woocommerce_thankyou’; $what_to_hook = ‘wl8OrderPlacedTriggerSomething’; $prioriy = 111; $num_of_arg = 1; add_action($hook_to, $what_to_hook, $prioriy, $num_of_arg); function wl8OrderPlacedTriggerSomething($order_id){ //do something… } For more reference dig into woocommerce/templates/checkout/thankyou.php

Make WooCommerce pages accessible for logged in users only

Put this in your functions.php file: function wpse_131562_redirect() { if ( ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout()) ) { // feel free to customize the following line to suit your needs wp_redirect(home_url()); exit; } } add_action(‘template_redirect’, ‘wpse_131562_redirect’); What does it do? We check if a not-logged-in user wants to see a WooCommerce page, … Read more

How to check if a plugin (WooCommerce) is active?

Your edit got me to this idea, there indeed is no function called »woocommerce«, there is a class »WooCommerce« though. One thing to be aware of is, that the check has to late enough, so that plug-ins are actually initialized, otherwise – obviously – the class won’t exists and the check returns false. So your … Read more

How to create a custom order status in woocommerce!

This is what I have used to create a custom order status called “Invoiced”. Add this to your theme’s functions.php // New order status AFTER woo 2.2 add_action( ‘init’, ‘register_my_new_order_statuses’ ); function register_my_new_order_statuses() { register_post_status( ‘wc-invoiced’, array( ‘label’ => _x( ‘Invoiced’, ‘Order status’, ‘woocommerce’ ), ‘public’ => true, ‘exclude_from_search’ => false, ‘show_in_admin_all_list’ => true, ‘show_in_admin_status_list’ … Read more

How to correctly add Javascript in functions.php

Your $scr in your wp_register_script() function is wrong. Given that your functions.php is inside your plugin, and your removeArrows.js is in the root of your plugin, your $scr should look like this plugins_url( ‘/removeArrows.js’ , __FILE__ ) Another point of note, it is always good practice to load your scripts and styles last. This will … Read more

Display All Products by Category with WooCommerce

Figured it out! The code below automatically lists all categories and each categories posts! $args = array( ‘number’ => $number, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘hide_empty’ => $hide_empty, ‘include’ => $ids ); $product_categories = get_terms( ‘product_cat’, $args ); $count = count($product_categories); if ( $count > 0 ){ foreach ( $product_categories as $product_category ) { … Read more

Woocommerce Add Variation Product to Cart from custom link [closed]

i currently work on a woocommerce v2.1.12 shop and it seems they chaged that behavior. my ajax url to add items to the cart has to look like this: ?add-to-cart=[PRODUCT-ID]&variation_id=[VARIATION-ID]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG] example: http://example.com/store/category/product/?add-to-cart=239&variation_id=240&attribute_pa_size=48-2&attribute_pa_color=gold this adds a specific product to the cart and also sets the variation attributes in the cart. you can even set the quantity … Read more

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