• Resolved eephyne

    (@eephyne)


    Hello

    It surely exists already, but I didn’t find anything useful.
    I have pw gift card plugin, and sometimes I need to make order manually (ex:a grandma that isn’t used to internet).
    I make the order manually and add the gift card but all the metadata needed by the plugin isn’t added automatically (like the message, recipient, etc…), I can add them manually, but that’s not efficient and if I make the order with the customer on the phone that’s not easy at all.
    Is there a way to add all those metadatas when I add the item on the cart ?

    Thanks for your time

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @eephyne

    Thanks for reaching out!

    Firstly, I apologize for the delayed response.

    If I understand you correctly, you would like to add the metadata needed by the PW gift card plugin when you create a manual order, right?

    By any chance, are you referring to the PW WooCommerce Gift Cards plugin here?

    If so, since this is a third-party plugin which we don’t provide support for (please see our Support Policy here), it would be best reaching out to the plugin’s developers or post to the proper forum thread for further assistance here:

    https://www.ads-software.com/support/plugin/pw-woocommerce-gift-cards/

    All the best and hopefully, the issue will be fixed soon.

    Thanks!

    Thread Starter eephyne

    (@eephyne)

    No problem for the delay, thanks for your time.

    You did understand exactly my need.
    I know that this is for a third party plugin but it seem to use core-parts of woocommerce and my question was mainly about woocommerce behavior (at least it seems so).
    I could ask how to do that with a normal product and not with a product linked to a plugin.
    I don’t mind modifying the code, I’ll do it all the time to bend the plugins to my needs.
    maybe I could add the metadata field using a WC hook ?

    Saif

    (@babylon1999)

    Hello @eephyne,

    I understand, but I’m afraid custom coding/solutions are not within our scope of support.

    That said, I found the following thread on StackOverflow with the same questions: https://stackoverflow.com/questions/46878943/how-can-i-populate-meta-fields-of-a-woocommerce-manual-order

    I trust this points you in the right direction.

    Cheers!

    Thread Starter eephyne

    (@eephyne)

    hello again.

    the SO thread was about how to populate not about adding new metadata.

    I posting my solution here in case someone search something similar.
    Its probably not ideal in all case but seem to work fine for my case.

    function add_custom_metada_to_gift_card($item_id, $item, $product ) {
    	//list of meta_data to add
    	$meta_key_list = [
    		'pw_gift_card_amount',
    		'pw_gift_card_to',
    		'pw_gift_card_recipient_name',
    		'pw_gift_card_from',
    		'pw_gift_card_message',
    		'pw_gift_card_email_design_id'
    	];
    	
    	if ($item['product_id'] == 1677) { 	//only add for specific product_id, chang it to yours
    			foreach ($meta_key_list as $metakey) {
    				if (!$item->meta_exists($metakey)) {
    					$item->add_meta_data($metakey,' ');
    					$item->save_meta_data();
    				}
    			}
    	}
    }
    add_filter('woocommerce_before_order_itemmeta','add_custom_metada_to_gift_card',10,3);

    hope it’ll help someone.

    Hi @eephyne

    I’m glad you were able to find a solution to your inquiry here and thanks for sharing it with the community too! ??

    Meanwhile, if you have a few minutes, we’d love it if you could leave us a review:

    https://www.ads-software.com/support/plugin/woocommerce/reviews/

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘automatically add metadata on manual order’ is closed to new replies.