Skip to content

Instantly share code, notes, and snippets.

@furahaclothing
furahaclothing / gist:71591dcffed7e498e162
Created July 13, 2014 07:13
welcart クーポン機能 *エラー表示検証する*
//welcart クーポンコード
add_filter('usces_order_discount', 'coupon_order_discount', 10, 2);
function coupon_order_discount($discount, $cart){
global $usces;
$entry = $usces->cart->get_entry();
$total_items_price = $usces->get_total_price();
if($entry['custom_order']['coupon'] == 'クーポンコード'){
$discount = ceil($total_items_price * 0.1 * -1);
}
return $discount;
<meta name="twitter:card" content="product">
<meta name="twitter:site" content="@twitter_account">
<meta name="twitter:creator" content="@twitter_account">
<meta name="twitter:title" content="<?php usces_the_itemName(); ?>">
<meta name="twitter:description" content="<?php echo get_post_meta($post->ID ,'wccs_詳細' ,true); ?>">
<meta name="twitter:image" content="<?php usces_the_itemImageURL(0); ?>">
<meta name="twitter:data1" content="<?php usces_crform(usces_the_firstPrice('return'),true, false); ?>">
<meta name="twitter:label1" content="Price">
<meta name="twitter:data2" content="<?php echo get_post_meta($post->ID , 'wccs_サイズ' ,true); ?>">
<meta name="twitter:label2" content="Size">
@furahaclothing
furahaclothing / gist:a9ba180de54891e02d8f
Created June 4, 2014 13:54
wordpress-twitter card
<meta name="twitter:card" value="summary" />
<meta name="twitter:url" value="<?php echo get_permalink(); ?>" />
<meta name="twitter:title" value="<?php echo get_the_title(); ?>" />
<meta name="twitter:description" value="<?php echo get_the_excerpt(); ?>" />
<meta name="twitter:image" value="<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>" />
<meta name="twitter:site" value="@twitter_account" />
<meta name="twitter:domain" content="your URL"/>
<meta name="twitter:creator" value="@twitter_account" />
@furahaclothing
furahaclothing / gist:bba575c6fcce4243d8ab
Created May 7, 2014 10:31
welcart消費税別にした際、合計金額に消費税を足す
//総合計金額をフィルター
add_filter('usces_filter_set_cart_fees_total_full_price', 'my_filter_set_cart_fees_total_full_price', 10, 6);
function my_filter_set_cart_fees_total_full_price(){
global $usces;
$args = func_get_args();
$tax = $usces->getTax( $args[1] );
$total_full_price = $args[1] + $tax + $args[2] + $args[3] + $args[4] + $args[5];
@furahaclothing
furahaclothing / gist:9504574
Created March 12, 2014 10:46
荷物追跡サービスのフォーム
<script type="text/javascript">
<!--
function data_in(){
//フォームデータ入力用変数
var denpyou;
var kaisha;
var url;
url = new Array();
@furahaclothing
furahaclothing / gist:9306656
Created March 2, 2014 13:37
wp-customer-reviewの平均評価、総評価数
/*add before get_aggregate_reviews($pageID) */
function get_average_rating() {
global $post;
$this->get_aggregate_reviews($post->ID);
$average_score = number_format($this->got_aggregate["aggregate"], 1);
return $average_score * 20; // 20% for each star if having 5 stars
}
/*do_the_content($original_content), just after $the_content = ''; add the following:*/
@furahaclothing
furahaclothing / tracking
Created March 2, 2014 13:30
荷物トラッキングの検索
<?php
//エラー処理
$kaisha = (!isset($_POST['kaisha'])) ? null : $kaisha = $_POST['kaisha'];
$denpyou = (!isset($_POST['denpyou'])) ? null : $denpyou = $_POST['denpyou'];
$submit = (!isset($_POST['submit'])) ? null : $submit = $_POST['submit'];
//URL設定
//クロネコヤマト
$url['1'] = "http://jizen.kuronekoyamato.co.jp/jizen/servlet/crjz.b.NQ0010?id=".$denpyou;
//佐川急便
$url['2'] = "http://k2k.sagawa-exp.co.jp/p/web/okurijosearch.do?okurijoNo=".$denpyou;
@furahaclothing
furahaclothing / wpfp-page-template
Created January 29, 2014 09:10
WP favorite post テンプレート
<div class="entry-text"><?php wpfp_clear_list_link(); ?></div>
<?php $favorite_post_ids = wpfp_get_user_meta() ?>
<?php if ($favorite_post_ids):
$favorite_post_ids = array_reverse($favorite_post_ids);
$post_per_page = 20;
$page = intval(get_query_var('paged'));
query_posts(array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page)); ?>
<div id="fave_posts_thumbnails">
<?php while ( have_posts() ) : the_post(); ?>
<div class="thumb-gallery"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute() ); ?>"><?php usces_the_itemImage($number = 0, $width = 150, $height = 150 ); ?></a></a><br><div class="remove-link"><?php wpfp_remove_favorite_link(get_the_ID());?></div></div>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
//上記を変更
<div id="post">
@furahaclothing
furahaclothing / gist:8574421
Created January 23, 2014 07:29
post_class()からhentryクラスを抜く(構造化データ)
function remove_hentry( $classes ) {
$classes = array_diff($classes, array('hentry'));
return $classes;
}
add_filter('post_class', 'remove_hentry');