Skip to content

Instantly share code, notes, and snippets.

@neltseng
neltseng / add disqus tab
Last active August 29, 2015 14:21
新增 Disqus tab
add_filter('woocommerce_product_tabs', 'cwp_woo_disqus_tab');
function cwp_woo_disqus_tab($tabs) {
$tabs['disqus_tab'] = array('title' => __('留言') , 'priority' => 50, 'callback' => 'cwp_woo_disqus_tab_content');
return $tabs;
}
function cwp_woo_disqus_tab_content() {
/**
* Changes the redirect URL for the Return To Shop button in the cart.
*
* @return string
*/
function wc_empty_cart_redirect_url() {
return 'http://yourdomain.com/your-page/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
@neltseng
neltseng / WooCommerce Custom Checkout Field
Last active January 8, 2016 14:46
WooCommerce Custom Checkout Field
// WooCommerce 台灣結帳表單 城市下拉選項
add_filter('woocommerce_states', 'cwp_woocommerce_tw_states');
function cwp_woocommerce_tw_states($states) {
$states['TW'] = array(
'基隆市' => '基隆市',
'台北市' => '台北市',
'新北市' => '新北市',
@neltseng
neltseng / WooCommerce Checkout Field Order
Created April 21, 2015 19:50
WooCommerce Checkout Field Order
// WooCommerce 自訂結帳欄位排序
add_filter('woocommerce_default_address_fields', 'cwp_custom_address_fields');
function cwp_custom_address_fields($fields) {
// 依照需要的欄位調整順序
$fields2['country'] = $fields['country'];
$fields2['first_name'] = $fields['first_name'];
$fields2['last_name'] = $fields['last_name'];
@neltseng
neltseng / WooCommerce Taiwan States Dropdown
Last active January 13, 2022 02:08
WooCommerce Taiwan States Dropdown
// WooCommerce 台灣結帳表單 城市下拉選項
add_filter('woocommerce_states', 'cwp_woocommerce_tw_states');
function cwp_woocommerce_tw_states($states) {
$states['TW'] = array(
'基隆市' => '基隆市',
'台北市' => '台北市',
'新北市' => '新北市',
@neltseng
neltseng / Google Knowledge Graph Sinppets for WordPress
Last active December 5, 2017 03:51
Google Knowledge Graph Sinppets for WordPress
// 企業用 Google Knowledge Graph
function cwp_google_knowledge_graph() {
if (is_front_page()) {
echo '<script type="application/ld+json">
{ "@context" : "http://schema.org",
"@type" : "Organization",
"name" : "cloudwp", //機構名稱
"url" : "https://cloudwp.pro", //網站網址
"logo" : "https://assets.cloudwp.pro/images/logo-gkg.png", //logo連結
"contactPoint" : [