Infoga en meta-tagg i sidhuvudet
// viewport meta-tag - förhindra zoom
add_action( 'wp_head', 'add_viewport_meta_tag' , '1' );
function add_viewport_meta_tag() {
    echo '<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">';
}
Infoga en script på "Tack-sidan" i WooCommerce
add_action( 'woocommerce_thankyou', 'conversion_tracking_thank_you_page' );
function conversion_tracking_thank_you_page() {
?>
   <script type="text/javascript">
	  gtag('event', 'conversion', {
		  'send_to': 'AW-XXX....',
		  'transaction_id': ''
	  });
   </script>
<?php
}
Hämta en Array med Produkt ID från specifik kategori
// get_products_by_cat('slugen'); OUTPUTS = { ids: [1,2,3..] }
function get_products_by_cat($cat) {
    $content = wc_get_products(array(
      'category' => array($cat),
    ));
    $ids = array();
    foreach ($content as $addon_product) {
      $ids[] = $addon_product->get_id();
    }
    return $ids;
}
Kortkod för att visa produkter från en Array med Produkt ID
add_shortcode('addons', 'shortcode_addons');
function shortcode_addons($atts) {
  $output = '<ul class="products addons">';
  $arr = explode(', ', $atts['ids']);

  foreach ($arr as $id) {
    $product = wc_get_product($id);
    $output .= '<li class="ast-article-single ast-woo-product-no-review align-center box-shadow-1 box-shadow-0-hover ast-product-gallery-layout-horizontal ast-product-gallery-with-no-image ast-product-tabs-layout-vertical ast-qv-on-image product type-product post-920 status-publish instock product_cat-tillval has-post-thumbnail virtual purchasable product-type-simple">
			<div class="astra-shop-thumbnail-wrap">
				<a href="#"
					class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
					<img alt="" src="' . wp_get_attachment_url($product->get_image_id()) . '" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" />
				</a>
			</div>
			<div class="astra-shop-summary-wrap">
				<a href="#" class="ast-loop-product__link">
					<h2 class="woocommerce-loop-product__title">' . $product->name . '</h2>
					<p>' . $product->post->post_excerpt . '</p>
				</a>
				<span class="price">
					<span class="woocommerce-Price-amount amount"><bdi>' . $product->price . '&nbsp;
					<span class="woocommerce-Price-currencySymbol">kr</span></bdi></span>
				</span>
			</div>';

    $output .= '<form class="addon-purchase-form" onsubmit="event.preventDefault();">';
    if ($product->is_type('variable')) {
      $handle = new WC_Product_Variable($id);
      $variation = $handle->get_children();
      $output .= '<select class="addon-variation">';
      foreach ($variation as $value) {
        $single_variation = new WC_Product_Variation($value);
        $output .= '<option value="' . $value . '">' . implode(" / ", $single_variation->get_variation_attributes()) . '    ' . $single_variation->price . ' ' . get_woocommerce_currency_symbol() . '</option>';
      }
      $output .= '</select><input name="variation_id" type="hidden" value="" />';

      if (get_field('is_baloon', $id)) {
          $output .= '<label>Siffror:</label><input type="number" class="input-text qty text" step="1" min="1" max="99" name="baloon" value="1" title="Antal år" size="4" placeholder="19 år" inputmode="numeric">';
      } else {
          $output .= '<input type="hidden" name="quantity" value="1">';
      }
    } else if ($product->is_type('simple')) {
      $output .= '<div class="quantity buttons_added">
					<a href="javascript:void(0)" class="minus">-</a>
					<label class="screen-reader-text" for="quantity">Kvantitet</label>
					<input type="number" class="input-text qty text" step="1" min="1" max="" name="quantity" value="1" title="Antal" size="4" placeholder="" inputmode="numeric">
					<a href="javascript:void(0)" class="plus">+</a>
				</div>';
    }
    $output .= '<input name="product_id" type="hidden" value="' . $id . '" /><button class="button primary addon_to_cart" type="submit" data-quantity="1">Lägg i varukorg</button></form></li>';
  }

  $output .= '</ul>';
  return $output;
}

add_shortcode('tillval', 'tillval_products');
function tillval_products() {
    $str = implode(", ", get_products_by_cat("tillval"));
    echo do_shortcode("[addons ids=\"$str\"]");
}