ResolvedFood Addon Values to PHP?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33715
    sarawsmn
    Participant

    Hi, we would like to connect the website to the cash-register at the physical store so that all of the orders pass through the register.
    Is it possible to get the Lafka theme food-addon values to a functions.php file?
    If not, would PPOM work with this theme for addons instead of built-in global addons? https://wordpress.org/plugins/woocommerce-product-addon/
    Many thanks,

    #33723
    Althemist
    Keymaster

    Hi sarawsmn,

    Basically, all the information should be available as the addons are stored as order meta data. I’ll ask our lead developer and CTO Alex to step in and give you more information. Please, allow a bit more time for answer.

    #33732
    sarawsmn
    Participant

    I appreciate that, looking forward to more info…

    #33752
    Alex
    Keymaster

    Hi sarawsmn,

    By design the addon data is not meant to be extractable from the order, but I prepared a code you can use to get the addons for a order by given order id. Please note that you have to create an array with your addon labels:

    add_action( 'init', function () {
        $order_id = 5557;
        // Manually enter all your addon labels
    	$addon_names_list = array(
    		'Accessories',
    		'Gift Wrapping',
    	);
    	/** @var WC_Order $order */
    	$order = wc_get_order( $order_id );
    	/** @var []WC_Order_Item $order_items */
    	$order_items = $order->get_items();
    	foreach ( $order_items as $order_item ) {
    		/** @var []WC_Meta_Data $order_meta_data */
    		$order_meta_data_array = $order_item->get_meta_data();
    		foreach ( $order_meta_data_array as $item ) {
    			foreach ( $addon_names_list as $addon ) {
    				$meta_data = $item->get_data();
    				if ( strpos( $meta_data['key'], $addon ) !== false ) {
    					echo $meta_data['key'] . ': ' . $meta_data['value'];
    				}
    			}
    		}
    	}
    } );

    On the other hand, you should be able to use another plugin which provides such functionality, but you need to disable the Addons in Lafka from Theme Options -> Shop -> Product Addons

    Regards,
    Alex

    #33762
    sarawsmn
    Participant

    Hi Alex, first of all thank you so much for creating a piece of code especially! This is an interesting approach and it might just solve our issue… we’ll get to work on it 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register