2012年1月28日土曜日

CS-Cart SSLから抜けるとトップページに戻ってしまう

CS-Cartの仕様なのかこちらのRewriteRuleの設定を間違っているのか不明だけど「SSL使用ページにアクセスした後はHTTPS接続を維持」にチェックが入っていないと、カートページでカートに入っている商品をクリックしてしまうと商品詳細ページではなくトップページに飛ばされる。

https://〜/index.php?dispatch=checkout.cart

カートに入っているサムネイル、商品名のリンクをクリックすると
https://〜/index.php?dispatch=products.view&product_id=1

http://〜/index.php

できれば


https://〜/index.php?dispatch=checkout.cart

カートに入っているサムネイル、商品名のリンクをクリックすると
https://〜/index.php?dispatch=products.view&product_id=1


http://〜/index.php?dispatch=products.view&product_id=1

となって欲しい・・・

2012年1月27日金曜日

CS-CartをFastCGIで運用するときに

個人的なメモ

mod_fastcgiのバージョンが2.4.6の時、
Apache2+FastCGI(mod_fastcgi)+PHP-FPMの環境で納品書(PDF)をダウンロードすると

FastCGI: comm with server "/var/www/fcgi-bin/php-fpm" aborted: error parsing headers: duplicate header 'Content-Type', referer: ...

とInternal Serverエラーが出る

mod_fastcgiのバグ?らしいのでSnapshot版の http://www.fastcgi.com/dist/mod_fastcgi-SNAP-0811090952.tar.gz と入れ替える。
mod_fastcgi-SNAP-0910052141.tar.gzの方が新しいようだけど未検証。

2012年1月25日水曜日

CS-Cart パンくずリストをリッチスニペット化

skins/basic/customer/common_templates/breadcrumbs.tplを修正

http://support.google.com/webmasters/bin/answer.py?hl=ja&answer=185417&topic=1088474&ctx=topic を参考に

http://www.google.co.jp/webmasters/tools/richsnippets で確かめる

修正例


{* $Id$ *}

{if $breadcrumbs && $breadcrumbs|@sizeof > 1}
<div class="breadcrumbs">
{strip}
{foreach from=$breadcrumbs item="bc" name="bcn" key="key"}
{if $key != "0"}
<img src="{$images_dir}/icons/breadcrumbs_arrow.gif" class="bc-arrow" border="0" alt="&gt;" />
{/if}
{if $bc.link}
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="{$bc.link|fn_url}"{if $additional_class} class="{$additional_class}"{/if} itemprop="url"><span itemprop="title">{$bc.title|unescape|strip_tags|escape:"html"}</span></a>
</span>
{else}
{$bc.title|unescape|strip_tags|escape:"html"}
{/if}
{/foreach}
{/strip}
</div>
{/if}

2012年1月20日金曜日

CS-Cart PayPal Express Checkoutボタンを日本語にする

PayPal Express Checkoutを有効にするとカートページにExpress Checkoutボタン現れる。


そのままだと英語圏向けのボタン表示なので日本語向けボタンに変更する。


ボタンはハードコーディングされているので payments/paypal_express.php の134行目付近

if (!empty($_payment_id) && !empty($_SESSION['cart']['products']))  {
    $lang = array(
        'EN' => 'en_US',
        'JP' => 'ja_JP',
    );
    $lang_code = isset($lang[CART_LANGUAGE]) ? $lang[CART_LANGUAGE] : 'en_US';
    $checkout_buttons[] = '
        <html>
        <body>
        <br/>
        <form name="pp_express" action="'. Registry::get('config.current_location') . '/payments/paypal_express.php" method="post">
            <input name="_payment_id" value="'.$_payment_id.'" type="hidden" />
            <input src="https://www.paypal.com/' . $lang_code . '/i/btn/btn_xpressCheckout.gif" type="image" />
            <input name="mode" value="express" type="hidden" />
        </form>
        </body>
        </html>';

CS-Cart 購入画面のコメント欄を削除する

skins/basic/customer/addons/my_changes/hooks/checkout/notes.override.tpl

{* $Id: customer_notes.tpl 9403 2010-05-07 13:11:06Z klerik $ *}
<!-- //-->


2012年1月11日水曜日

CS-Cart 携帯電話対応アドオンでPHP Noticeエラー

携帯電話対応アドオンを有効後、端末でアクセスするとDIR_SKINS定数を再定義するようでNoticeエラーが発生する
PHP Notice:  Constant DIR_SKINS already defined in /var/www/html/config.php on line 41
if (!defined(DIR_SKINS))という感じでとりあえず回避

2012年1月10日火曜日

CS-Cartのタイトルを変更する

skins/basic/customer/index.tpl
<title>
{if $page_title}
  {$page_title|escape:"html"}
{else}
  {assign var='breadcrumbs_reverse' value=$breadcrumbs|array_reverse}
  {assign var='breadcrumbs_reverse_count' value=$breadcrumbs_reverse|count}
  {foreach from=$breadcrumbs_reverse item=i name="bkt"}
   {if $_REQUEST.dispatch == 'products.view'}
    {if $smarty.foreach.bkt.first}{$i.title|unescape|strip_tags|escape:"html"}{/if}
   {else}
    {if !$smarty.foreach.bkt.last}{$i.title$i.title|unescape|strip_tags|escape:"html"}{if $breadcrumbs_reverse_count -1 > $smarty.foreach.bkt.iteration} :: {/if}{/if}
   {/if}
  {/foreach}
{if !$skip_page_title}{if $breadcrumbs_reverse|count > 1} | {/if}{$location_data.page_title}{/if}
{/if}
</title>
これでカテゴリページは、小カテゴリ :: 大カテゴリ | サイト名
商品ページは、商品名 | サイト名となる。

2012年1月8日日曜日

CS-Cart HTMLエディタ「CKEditor」の出力フォーマットを変更する

CKEditorの出力ソースをカスタマイズする方法
CKEditorはデフォルトだとソースを勝手にインデントしたり改行を入れるので、それを制御する。
/js/editors/ckeditor.editor.js の CKEDITOR.replace(elm.attr('id'), {}); の次あたり(26行目付近)に
CKEDITOR.on('instanceReady', function(ev) {
    ev.editor.dataProcessor.writer.indentationChars = '';
    var tags = ['div',  'h1','h2','h3','h4','h5','h6', 'p', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'table', 'tbody', 'tr', 'th', 'td', 'pre', 'address'];
    for (var key in tags) {
        ev.editor.dataProcessor.writer.setRules(tags[key], {
            breakAfterOpen : false
        });
    }
});

editor.dataProcessor.writer.indentationChars でインデント文字を指定する。タブの場合は\t、スペースの場合は' '、インデントさせない場合は空白。
editor.dataProcessor.writer.setRules で指定タグで改行させないを指定する。
http://cksource.com/forums/viewtopic.php?t=14493