• Resolved imdevnoel

    (@imdevnoel)


    Hello good day,

    I don’t know if this is an issue as I have a concern regarding when buying gift voucher using paypal as payment method. My concern is when a customer bought a gift voucher using paypal the gift voucher is not automatically sent to the customer when payment is already been done. The order status will be put on hold and admin needs to check and send the gift voucher code manually. I recently updated the site’s woocommerce version to 4.9.2 and Yith WooCommerce Gift cards to 2.0.6.

    Is there a way it will be automatically received the gift voucher code without manually sending it? Only the recent order starting Feb. 05, 2021. It maybe due to the update. I don’t know if this was on the core woocommerce side or in the yith plugin itself. Nothing was wrong before as there was an order last Feb. 02, 2021. Due to the fact that it only happen when it was updated. Though I was planning on updating the yith to 2.0.10 and woocommerce 5.0.0 but if the problem / issue is still there then I may not need to update it. We were also forbid to update the yith plugin as there is a couple of custom code on the custom template.

    Thank you and hoping for an early reply.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hello there,
    hope you are doing well! ??

    By default, the gift cards are created and sent when the order turns to “Processing” or “Completed” status, to avoid sending the gift card without the payment is confirmed.

    Anyway, if you want to auto-complete the orders which contain a gift card, you have to add the next code in the functions.php of your active theme:

    
    if( !function_exists('yith_wcgc_woocommerce_auto_complete_order') ) {
    
    	add_action( 'woocommerce_thankyou', 'yith_wcgc_woocommerce_auto_complete_order' );
    
    	function yith_wcgc_woocommerce_auto_complete_order( $order_id ) {
    		if ( ! $order_id ) {
    			return;
    		}
    
    		$order       = wc_get_order( $order_id );
    		$order_items = $order->get_items();
    
    		$product_types_array = array();
    
    		foreach ( $order_items as $item_id => $item_data ) {
    			$product               = wc_get_product( $item_data['product_id'] );
    			$product_types_array[] = $product->get_type();
    		}
    
    		$fulldiff = array_merge(array_diff($product_types_array, array( "gift-card" )), array_diff(array( "gift-card" ), $product_types_array));
    
    		if ( empty( $fulldiff ) )
    			$order->update_status( 'completed' );
    
    	}
    }

    Could you check it and let us know, please?

    Have a nice day!

    Thread Starter imdevnoel

    (@imdevnoel)

    Hello good day,

    Sorry, for the late reply. Thank you for the your reply and will try to apply your code.

    Thank you once again.

    Plugin Support Alexis Salazar

    (@asaldel)

    Hello there.

    Perfect. You are welcome!

    We’ll set this topic on solved.

    If you have any other problem, don’t hesitate to open a new one.

    Have a good day.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Not automatically sending voucher code using paypal’ is closed to new replies.