function to add note on single Woo Commerce product page for downloadable variations

For variable product, it’s not the product that you need to test but the variations : add_action( ‘woocommerce_before_add_to_cart_button’ , function () { global $product; $downloadable = FALSE; if (“simple” === $product->get_type()) { $downloadable = $product->is_downloadable(); } elseif (“variable” === $product->get_type()) { $variations = $product->get_available_variations(); foreach ($variations as $variation) { if ($variation[“is_downloadable”]) { $downloadable = TRUE; … Read more

How can I add an additional action button into the woocommerce admin order page?

Add this below code your current active theme functions.php file add_filter( ‘woocommerce_admin_order_actions’, ‘add_custom_order_status_actions_button’, 100, 2 ); function add_custom_order_status_actions_button( $actions, $order ) { if ( $order->has_status( array( ‘processing’ ) ) ) { // The key slug defined for your action button $action_slug = ‘invoice’; $status = $_GET[‘status’]; $order_id = method_exists($the_order, ‘get_id’) ? $the_order->get_id() : $the_order->id; // … Read more

How to Show Single Product – 4 Data by ID in Custom Page without over-riding the existing Woo-Commerce

Your query returns an array of posts (query all products belonging to specific cat product cat), in your case it looks like there’s ony one. To display a list on your custom page you’ve to iterate the array with: $args = array( ‘post_type’ => ‘product’, ‘product_cat’ => ‘category-id’ );//note that this looks like a mistake, … Read more

WordPress select field – show current value?

By referencing to the source code, this function supports an argument called value which you can pass one of the keys inside the options array like this: function woo_add_spin() { woocommerce_wp_select([ ‘id’ => ‘_select_nf’, ‘label’ => __( ‘Select #spins: ‘, ‘woocommerce’ ), ‘selected’ => true, ‘value’ => ’24’, ‘options’ => [ ’24’ => __( ’24’, … Read more

Add custom order meta to Order Completed email

paste the below code your active theme functions.php file add_filter( ‘woocommerce_email_order_meta_fields’,’custom_order_email_order_meta_data’, 10, 3 ); function custom_order_email_order_meta_data( $fields, $sent_to_admin, $order ) { $fields[‘wpcf-purchase-student’] = array( ‘label’ => __( ‘purchase amount’, ‘woocommerce’ ), ‘value’ => get_post_meta( $order->id, ‘wpcf-purchase-student’, true ) ); return $fields; }

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