/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
/* Customized Solution by Nucleus System */
// Set HERE your targetted products IDs:
$targetted_products = array( 3038 ); //if product id is crony
$order = wc_get_order( $order_id );
if ( $order->get_user_id() > 0 ) {
foreach ( $order->get_items() as $order_item ) {
// Here we detect if the a target product is part of this order items
if ( in_array( $order_item['product_id'], $targetted_products ) ){
// I think tha this is not really needed as it's set when an order has been paid…
update_user_meta( $order->get_user_id(), 'paying_customer', 1 ); // 1 => true
// Remove all roles and set 'editor' as user role (for current user)
$user = new WP_User( $order->get_user_id() );
$user->set_role( 'crony' );
// Product is found, we break the loop…
break;
}
}
}
$order->update_status( 'completed' );
}
//
// add_action( 'woocommerce_order_status_completed', 'custom_action_on_completed_customer_email_notification' );
// function custom_action_on_completed_customer_email_notification( $order_id ) {
//
// // Set HERE your targetted products IDs:
// $targetted_products = array( 3038 );
//
// $order = wc_get_order( $order_id );
//
// if ( $order->get_user_id() > 0 ) {
// foreach ( $order->get_items() as $order_item ) {
// // Here we detect if the a target product is part of this order items
// if ( in_array( $order_item['product_id'], $targetted_products ) ){
//
// // I think tha this is not really needed as it's set when an order has been paid…
// update_user_meta( $order->get_user_id(), 'paying_customer', 1 ); // 1 => true
//
// // Remove all roles and set 'editor' as user role (for current user)
// $user = new WP_User( $order->get_user_id() );
// $user->set_role( 'crony' );
// $user->add_role( 'subscriber' );
//
// // Product is found, we break the loop…
// break;
// }
// }
// }
// }
All muhaza's note in developing website. Front-end & uiux method. Real life implementation for webdesigner.
Thursday, 14 December 2017
Woocommerce : Specific item skip cart direct to checkout
add_filter( 'woocommerce_add_to_cart_redirect', 'woo_redirect_checkout' );
function woo_redirect_checkout() {
global $woocommerce;
$desire_product = '3038'; /* <-- this product id */
//Get product ID
$product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $_POST['add-to-cart'] );
//Check if current product is subscription
if ( $product_id == $desire_product ){
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
exit;
} else {
$cart_url = $woocommerce->cart->get_cart_url();
return $cart_url;
exit;
}
}
function woo_redirect_checkout() {
global $woocommerce;
$desire_product = '3038'; /* <-- this product id */
//Get product ID
$product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $_POST['add-to-cart'] );
//Check if current product is subscription
if ( $product_id == $desire_product ){
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
exit;
} else {
$cart_url = $woocommerce->cart->get_cart_url();
return $cart_url;
exit;
}
}
Meta tag : Change mobile browser address to color theme
<meta name="theme-color" content="#ff6600" />
http://www.wpbeginner.com/wp-tutorials/how-to-change-the-color-of-address-bar-in-mobile-browser-to-match-your-wordpress-site/
http://www.wpbeginner.com/wp-tutorials/how-to-change-the-color-of-address-bar-in-mobile-browser-to-match-your-wordpress-site/
Monday, 4 December 2017
Woo commerce
Add content below add to cart button
https://chiefthemes.com/woocommerce-add-content-blow-add-to-cart-button/
https://chiefthemes.com/woocommerce-add-content-blow-add-to-cart-button/
Subscribe to:
Posts (Atom)
email mailto: pretext
<a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...
-
Looking at vue-cli repository I see two different ways of scaffolding vue projects. The v3 (beta) version, installed as npm install ...
-
component need at least this 3 component file 1. customers.component.ts import { Component , OnInit } from '@angular/core...