snipt

Ctrl+h for KB shortcuts

PHP

add iva or cf to woocommerce invoices

1
2
3
4
5
<?php
global $wcdn;
$billing_cfs = $wcdn->print->get_order()->order_custom_fields['_billing_cf'];
echo(strtoupper($billing_cfs[0]));
?>
https://snipt.net/embed/ec663333031a904ee5562eea703c7e26/
https://snipt.net/raw/ec663333031a904ee5562eea703c7e26/
ec663333031a904ee5562eea703c7e26
php
PHP
5
2016-09-20T17:04:54
True
False
True
Jun 21, 2013 at 06:11 AM
/api/public/snipt/65166/
add-iva-or-cf-to-woocommerce-invoices
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">global</span> <span class="nv">$wcdn</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$billing_cfs</span> <span class="o">=</span> <span class="nv">$wcdn</span><span class="o">-&gt;</span><span class="na">print</span><span class="o">-&gt;</span><span class="na">get_order</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">order_custom_fields</span><span class="p">[</span><span class="s1">&#39;_billing_cf&#39;</span><span class="p">];</span> </span><span id="L-4"><a name="L-4"></a><span class="k">echo</span><span class="p">(</span><span class="nb">strtoupper</span><span class="p">(</span><span class="nv">$billing_cfs</span><span class="p">[</span><span class="mi">0</span><span class="p">]));</span> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
cf, codice, delivery, fiscale, invoice, iva, note, parita, woocommerce, wordpress, wp

PHP

Get link to product category by slug

1
2
3
4
5
6
<?php

  $cat=get_term_by('slug', 'cat_slug', 'product_cat');
  $url=get_term_link( (int) $cat->term_id, 'product_cat' );

?>
https://snipt.net/embed/8cba5ea847356df79097278a786daaee/
https://snipt.net/raw/8cba5ea847356df79097278a786daaee/
8cba5ea847356df79097278a786daaee
php
PHP
6
2016-09-29T22:19:50
True
False
False
Apr 18, 2013 at 05:50 AM
/api/public/snipt/59494/
get-link-to-product-category-by-slug
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$cat</span><span class="o">=</span><span class="nx">get_term_by</span><span class="p">(</span><span class="s1">&#39;slug&#39;</span><span class="p">,</span> <span class="s1">&#39;cat_slug&#39;</span><span class="p">,</span> <span class="s1">&#39;product_cat&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$url</span><span class="o">=</span><span class="nx">get_term_link</span><span class="p">(</span> <span class="p">(</span><span class="nx">int</span><span class="p">)</span> <span class="nv">$cat</span><span class="o">-&gt;</span><span class="na">term_id</span><span class="p">,</span> <span class="s1">&#39;product_cat&#39;</span> <span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
woocommerce, wordpress

PHP

Get the WooCommerce Shop URL

1
2
3
4
5
6
7
<?php 
//Get the WooCommerce Shop URL (this is the root category page) with the following:

$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );

//seen at http://www.foxrunsoftware.net/articles/wordpress/get-woocommerce-page-urls/
?>
https://snipt.net/embed/71271eac55982a993b479c6e954cea7e/
https://snipt.net/raw/71271eac55982a993b479c6e954cea7e/
71271eac55982a993b479c6e954cea7e
php
PHP
7
2016-09-30T00:55:27
True
False
False
Apr 18, 2013 at 05:24 AM
/api/public/snipt/59493/
get-the-woocommerce-shop-url
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">//Get the WooCommerce Shop URL (this is the root category page) with the following:</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="nv">$shop_page_url</span> <span class="o">=</span> <span class="nx">get_permalink</span><span class="p">(</span> <span class="nx">woocommerce_get_page_id</span><span class="p">(</span> <span class="s1">&#39;shop&#39;</span> <span class="p">)</span> <span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">//seen at http://www.foxrunsoftware.net/articles/wordpress/get-woocommerce-page-urls/</span> </span><span id="L-7"><a name="L-7"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
woocommerce, wordpress

PHP

Woocommerce - remove catalog ordering

1
2
3
<?php //Add to functions.php

remove_action('woocommerce_pagination', 'woocommerce_catalog_ordering', 20 );
https://snipt.net/embed/198f7f252e0cab44eeb92bc0dc37223e/
https://snipt.net/raw/198f7f252e0cab44eeb92bc0dc37223e/
198f7f252e0cab44eeb92bc0dc37223e
php
PHP
3
2016-09-29T07:15:13
True
False
False
/api/public/snipt/52937/
woocommerce-remove-catalog-ordering
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="c1">//Add to functions.php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nx">remove_action</span><span class="p">(</span><span class="s1">&#39;woocommerce_pagination&#39;</span><span class="p">,</span> <span class="s1">&#39;woocommerce_catalog_ordering&#39;</span><span class="p">,</span> <span class="mi">20</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
woocommerce

PHP

Woocommerce - disable breadcrumbs

1
2
3
<?php //Add to functions.php
	remove_action( 'woocommerce_before_main_content',
    'woocommerce_breadcrumb', 20, 0);
https://snipt.net/embed/5d20ce246f572b1c0e81e0cecde825fa/
https://snipt.net/raw/5d20ce246f572b1c0e81e0cecde825fa/
5d20ce246f572b1c0e81e0cecde825fa
php
PHP
3
2016-09-28T15:58:32
True
False
False
/api/public/snipt/52918/
woocommerce-disable-breadcrumbs
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="c1">//Add to functions.php</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">remove_action</span><span class="p">(</span> <span class="s1">&#39;woocommerce_before_main_content&#39;</span><span class="p">,</span> </span><span id="L-3"><a name="L-3"></a> <span class="s1">&#39;woocommerce_breadcrumb&#39;</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></pre></div> </td></tr></table>
woocommerce

PHP

Control number of columns in Woocommerce catalog

1
2
3
4
5
6
7
8
<?php 

//Just put it in functions.php

/* Number of columns in Woocommerce Loop */

global $woocommerce_loop;
$woocommerce_loop['columns'] = 2;
https://snipt.net/embed/7624e6a18a62988fa9e8b4afe3fcfb5a/
https://snipt.net/raw/7624e6a18a62988fa9e8b4afe3fcfb5a/
7624e6a18a62988fa9e8b4afe3fcfb5a
php
PHP
8
2016-09-29T21:09:40
True
False
False
/api/public/snipt/43423/
control-number-of-columns-in-woocommerce-catalog
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1">//Just put it in functions.php</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="cm">/* Number of columns in Woocommerce Loop */</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="k">global</span> <span class="nv">$woocommerce_loop</span><span class="p">;</span> </span><span id="L-8"><a name="L-8"></a><span class="nv">$woocommerce_loop</span><span class="p">[</span><span class="s1">&#39;columns&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span> </span></pre></div> </td></tr></table>
woocommerce, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.