Woocommerce – get_items() returns empty array

I am trying to write a function that will allow me to add product meta tags as additional order notes. Unfortunately, nothing works. After a few hours I decided to bring the function to the simplest form to see what does not work.

Each time I place an order for two products. I check my order and see two products. My function should create a note with the text "test 2" but creates a "test 0".
And I have no idea why.

function add_engraving_notes($order_id)
    $order = wc_get_order($order_id);
    $note = 'Test';

    $items = $order->get_items();
    $note .= count($items);

add_action('woocommerce_new_order', 'add_engraving_notes');

woocommerce – Quitar onchange del html con javascript

Estoy modificando un formulario de woocommerce, por el cual a través de unos select, voy mostrando los países de los correspondientes Continentes. Es decir cuando hago click en Europa del desplegable salen: España, Francia, Alemania, etc.

Bien, el problema está en que en woocommerce no puedo añadir onChange=”ponPaises(this.form)”
por lo cual no funciona el código, mi pregunta es .
¿ cómo podria detectar esos clicks fuera del formulario? es decir, que sea desde javascript ?

¡ Muchísimas gracias por vuestra ayuda !

un cordial saludo,

<meta charset="utf-8">
<meta name="description" content="ejercicios con javascript que permite obtener datos de los paises de centroamerica"/>
<meta name="keywords" content="ejercicio_paises, javascript, html, css"/>


    var paises = new Array()
    paises(1) = ("Elige país","España","Portugal","Alemania", "Francia","Reino Unido (UK)")
    paises(2) = ("Elige país","Argentina","Colombia","Perú")
    paises(3) = ("Elige país","México")
    paises(4) = ("Elige país","Miami")

    function ponPaises(formu)
    {   var elConti = formu.region.selectedIndex
        formu.pais.length = paises(elConti).length
        for (i=0; i<formu.pais.length; i++)
        {   formu.pais.options(i).text = paises(elConti)(i)
    function ponProvincias(formu)
    {   var elConti = formu.region.selectedIndex
        var elPais = formu.pais.selectedIndex
        formu.provincia.length = provincias(elConti)(elPais).length
        for (i=0; i<formu.provincia.length; i++)
        {   formu.provincia.options(i).text = provincias(elConti)(elPais)(i)
<select name="region" onChange="ponPaises(this.form)">
<option selected>Región</option>
<option>América Central</option>
<option>Estados Unidos</option>
<select name="pais" onChange="ponProvincias(this.form)">


sql – get woocommerce product image url and price from database

I want to get some product data directly from the database, currently I have this, but I’m missing the featured image URL:

  t.name AS product_category,
  t.term_id AS product_id,
  t.slug AS product_slug,
  tt.term_taxonomy_id AS tt_term_taxonomia,
  tr.term_taxonomy_id AS tr_term_taxonomia,
  MAX(CASE WHEN pm1.meta_key = '_price' then pm1.meta_value ELSE NULL END) as price,
  MAX(CASE WHEN pm1.meta_key = '_sku' then pm1.meta_value ELSE NULL END) as sku 
FROM wp_posts p 
LEFT JOIN wp_postmeta pm1 ON pm1.post_id = p.ID
LEFT JOIN wp_term_relationships AS tr ON tr.object_id = p.ID
JOIN wp_term_taxonomy AS tt ON tt.taxonomy = 'product_cat' AND tt.term_taxonomy_id = tr.term_taxonomy_id 
JOIN wp_terms AS t ON t.term_id = tt.term_id
WHERE p.post_type in('product', 'product_variation') AND p.post_status = 'publish' AND p.post_content <> ''
GROUP BY p.ID,p.post_title

Buying – WordPress WooCommerce site

I need a WordPress WooCommerce site built for ecommerce.

The primary product on the site will be POD items. The site needs to be connected to both printful and printify.

I have the domain, logo and customer images that can be used on the site. Everything else i’m flexible on (themes, layout etc)

Please PM me your portfolio and prices



woocommerce – Is it possible to checkout with 2 different shipping options on a single order?

This is regarding a marketplace in WooCommerce that has different vendors. Let’s say you are buying item A from Vendor 1 and item B from Vendor 2. And you would like to get the first item shipped to your home, but you want to pick up Item B, since it’s close to your home. Is it possible to checkout on a single order choosing a shipping method for item A and a different one for item B?


woocommerce – Formatting product prices in email orders

I’m trying to format prices in case of Indian Rupees. Below is my code and it works in case of email order on hold but how to make it work in case of order-complete?

   //Indian Currency Formatter
add_filter( 'formatted_woocommerce_price','ind_currency_formatter', 100, 1 );

    function ind_currency_formatter($price){
        global $user_currency;
            $price = preg_replace("/(d+?)(?=(dd)+(d)(?!d))(.d+)?/i", "$1,", str_replace( ',', '', $price ));
            return $price;
            return $price;

Woocommerce Product title update based on variation selected

i am trying to update the title of product based on variation selected.

For Ex: If the product name is FLORAL DRESS, then if i select the variation as PINK, then the product title should change as FLORAL DRESS – PINK.

Below code was working with older wordpress/woocommerce, now it seems to be broken.

Can someone please help updating this?

    add_filter( 'wp_footer','custom_product_title_script' );
function custom_product_title_script(){
    global $post;

    // Only single product pages
    if( ! is_product() ) return;

    // get an instance of the WC_Product Object
    $product = wc_get_product($post->ID);

    // Only for variable products
    if( ! $product->is_type( 'variable' ) ) return;

    // Here set your specific product attributes in this array (coma separated):
    $attributes = array('pa_color');

    // The 1st loop for variations IDs
    foreach($product->get_visible_children( ) as $variation_id ) {

        // The 2nd loop for attribute(s)/value
        foreach($product->get_available_variation( $variation_id )('attributes') as $key => $value_id ){
            $taxonomy = str_replace( 'attribute_', '', $key ); // Get the taxonomy of the product attribute

            // Just for defined attributes
            if( in_array( $taxonomy, $attributes) ){
                // Set and structure data in an array( variation ID => product attribute => term name )
                $data( $variation_id )($taxonomy) = get_term_by( 'slug', $value_id, $taxonomy )->name;

        <script type="text/javascript">
                // variables initialization
                var variationsData = <?php echo json_encode($data); ?>,
                    productTitle = $('.product_title').text(),
                    color = 'pa_color';

                // function that get the selected variation and change title
                function update_the_title( productTitle, variationsData, color ){
                    $.each( variationsData, function( index, value ){
                        if( index == $('input.variation_id').val() ){
                            $('.product_title').text(productTitle+' - '+value(color));
                            console.log('TITLE UPDATED');
                            return false;
                        } else {

                // Once all loaded
                    update_the_title( productTitle, variationsData, color );
                }, 300);

                // On live event: select fields
                $('select').blur( function(){
                    update_the_title( productTitle, variationsData, color );

How can I make a conditional checkbox on Woocommerce checkout?

I need to place an “I agree to my data being sent to X payment processor…” checkbox (Mandatory, unchecked) on the checkout form of Woocommerce. Ideally in the same spot where one agrees to Terms & Conditions. I would need it to be conditional based on the payment method chosen; so Paypal would have an “I agree to data being sent to Paypal…” box where Stripe would have “I agree… sent to stripe…” box.

I am absolutely not 100% fluent in PHP or coding for that matter, so if you do know of a way, perhaps you could just explain it quite simply?

Thank you so much!

functions – How to display custom option field in woocommerce orders in admin panel?

Actually this question has already answerd as i already checked but i am unable to comment on that question as i am using the same code but in my scenrio i am using options field and value is not reflecting in admin panel below is the code that i tried

//*Multiple Options Php - Select Occasion*/

add_filter( ‘woocommerce_checkout_fields’ , ‘my_custom_checkout_field_update_order_meta’ );

function my_custom_checkout_field_update_order_meta( $fields ) {
$fields(‘billing’)(‘myfield’) = array(
‘type’ => ‘select’,
‘id’ => ‘myfield’,
‘placeholder’ => __(‘Select Occasion’, ‘woocommerce’),
‘required’ => false,
‘class’ => array(‘form-row-wide’),
‘clear’ => false,
‘options’ => (
‘key1’ => __(‘Birthday’, ‘woocommerce’),
‘key2’ => __(‘Anniversary’, ‘woocommerce’),
‘key3’ => __(‘Congratulations’, ‘woocommerce’),
‘key4’ => __(‘Sorry’, ‘woocommerce’),
‘key5’ => __(‘Good Luck’, ‘woocommerce’),
‘key6’ => __(‘Thank You’, ‘woocommerce’),
‘key7’ => __(‘Get Well Soon’, ‘woocommerce’),
‘key8’ => __(‘Love’, ‘woocommerce’),
return $fields;

add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘edit_woocommerce_checkout_page’, 10, 1 );

function edit_woocommerce_checkout_page($order){
global $post_id;
$order = new WC_Order( $post_id );
echo ‘

‘.__(‘Occasion’).’: ‘ . get_post_meta($order->get_id(), ‘_myfield’, true ) . ‘