Manually create an order with a product ID woocommerce

I think you can use the following: $order->update_meta_data( ‘YOUR_META_KEY_HERE’, $note ); Remember to replace YOUR_META_KEY_HERE with your preferred key, Complete code: add_action( ‘gform_after_submission_56’, ‘post_to_third_party’, 10, 2 ); function post_to_third_party( $entry, $form ) { global $woocommerce; // use this to find out $entry output var_dump($entry); // Make sure to add hidden field somewhere in the form … Read more

Check if product variation image is from the variation itself or from the parent

Solution: If you check for the image ID with parameter $context=”edit”, you will only get a returned ID if the image is set directly to the variation. The code looks like this: $image_id = $variation->get_image_id(‘edit’); if ($image_id){ //Only if there is an image to the variation itself echo $image_id; } Ref: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#662-671

When creating a new product, auto assign it to all custom taxonomy woocommerce

For post types not using the block editor, you can use wp_terms_checklist_args filter to manipulate the selected terms of a hierarchical taxonomy. You can use the filter to set pre-selected terms like so, function auto_check_hierarchial_terms_on_new_post( $args, $post_id ) { // is it new post? if ( ‘auto-draft’ !== get_post_status($post_id) ) { return $args; } // … Read more

woocommerce ad custom button with custom link after add to cart for every product

As you can see in the wpse_add_custom_link_output callback function this echo the $html variable. So you can simply replace the following line $html=”<a href=””.$external_link.'” class=”custom-button-class” target=”_blank” title=”‘.__(‘External product link’,’woocommerce’).'”>’.$external_link.'</a>’; With something like $html=”<button type=”button”>BUY NOW</button>”;