發佈於

第26天-CSS字體加載跨域問題-如何解決設定.htaccess檔

第26天-CSS字體加載跨域問題-如何解決設定.htaccess檔
===
https://hackmd.io/s/Sk_RhTDNz 本文筆記網址

# 如果你的OPENCART購物車系統有分館的設定 也就是有2個網址的話
# 那麼你一定會遇到以下錯誤 字型不出現
![你一定會遇到以下錯誤 字型不出現](https://i.imgur.com/DjkHH6N.jpg)

## 在 .htaccess檔 加上此段就好了


#解決css加載字體跨域問題此招對自己架設主機者有效
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>

# 看問題解決了-沒錯誤了
![](https://i.imgur.com/trGHtee.jpg)

### 註 如果你有2個網址是http和https 可是你是使用代理https的服務器的話-因為你沒有該主機權限所以設這個也沒有用

## 附上本人 OPENCART v2.3.0.2 版 之完整的 .htaccess檔 設定

“`
# 阻止目錄列表
Options +FollowSymlinks
Options -Indexes

#解決css加載字體跨域問題此招對自己架設主機者有效
<FilesMatch “\.(ttf|otf|eot|woff|woff2)$”>
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin “*”
</IfModule>
</FilesMatch>

# 防止直接訪問文件 Prevent Direct Access to files
<FilesMatch “(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))”>
## 對於apache 2.2及更高版本,用這兩行替換 :
Order deny,allow
Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

# ———————————————————————–
# 定義MIME類型以確保Web服務器真正了解它們。
# Defining MIME types to ensure the web server actually knows about them.
# ———————————————————————–
<IfModule mod_mime.c>
AddType application/javascript js
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
AddType application/x-font-woff2 woff2
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</Ifmodule>

# ———————————————————————–
# Apache 的壓縮功能可壓縮js、css等靜態文件
# Compressing output.
# ———————————————————————–
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</Ifmodule>
“`



我這算簡單的設定了,國外的寫的更複雜

“`
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch “(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))”>
Require all denied
## For apache 2.2 and older, replace “Require all denied” with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an “Internal Server Error 500” after enabling any of the following settings, restore the # as this means your host doesn’t allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

Header unset ETag
FileETag None

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault “access plus 1 month”
# My favicon
ExpiresByType image/x-icon “access plus 1 year”
# Images
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
# CSS
ExpiresByType text/css “access plus 1 month”
# Javascript
ExpiresByType application/javascript “access plus 1 year”
ExpiresByType application/x-javascript “access plus 1 year”
# Resources
ExpiresByType application/x-javascript “access plus 1 year”
ExpiresByType application/x-javascript “access plus 1 year”
ExpiresByType application/x-javascript “access plus 1 year”
</IfModule>

# ———————————————————————–
# Defining MIME types to ensure the web server actually knows about them.
# ———————————————————————–
<IfModule mod_mime.c>
AddType application/javascript js
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
AddType application/x-font-woff2 woff2
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</Ifmodule>

# ———————————————————————–
# Compressing output.
# ———————————————————————–
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</Ifmodule>
“`


尋找OPENCART 台灣在地化工作者的聯絡方式

![OC+WP插件研究社 LINE討論群](https://i.imgur.com/98PXU2F.jpg)

OC+WP插件研究社 LINE討論群 http://line.me/R/ti/g/lzJUVUMW-0 網址要用LINE開
OC+WP插件研究社 LINE@帳號 https://line.me/R/ti/p/%40ijm8117i 這很少用

OC+WP插件研究社 其中之一 工程師的個人部落格 http://blog.bkk.tw/

OC+WP插件研究社 FB社團 https://www.facebook.com/groups/opencart.wordpress/

發佈於

OPENCART插件2.1.0改到2.3.0.2版-要改多少地方

———————————–
#OPENCART 插件 2.1.0 改到 2.3.0.2版 要改多少地方 你以為很少-其實很多 最少要3-4工作天
2.3.0.2版 => 3.0 那就 更花工時了 因為差異也很大

2017/11/10修改紀錄
以下不含前台程式光後台程式要改的差異
———————————–
1.類別名稱
class ControllerPaymentCheque extends Controller {
class ControllerExtensionPaymentCheque extends Controller {
————————————————————————————–
2.語言檔位置
$this->load->language(‘payment/ezship’);
$this->load->language(‘extension/payment/ezship’);
————————————————————————————–
3.樣板檔位置
$this->response->setOutput($this->load->view($this->module_path.’.tpl’, $this->data));
$this->response->setOutput($this->load->view(‘extension/payment/cheque’, $data));
$this->response->setOutput($this->load->view($this->module_path.’.tpl’, $this->data));
————————————————————————————–
$this->response->setOutput($this->load->view(‘shipping/ezship_shipment.tpl’, $data));
$this->response->setOutput($this->load->view(‘extension/shipping/ezship_shipment’, $data));
————————————————————————————–
4.權限檢查名稱
if (!$this->user->hasPermission(‘modify’, ‘shipping/ezship_shipment’)) {
if (!$this->user->hasPermission(‘modify’, ‘extension/shipping/ezship_shipment’)) {
5.連結位置
public function __construct( $registry ) {
parent::__construct( $registry );
$this->ssl = (defined(‘VERSION’) && version_compare(VERSION,’2.2.0.0′,’>=’)) ? true : ‘SSL’;
}
————————————————————————————–
6.存檔後返回頁
$this->response->redirect($this->url->link(‘extension/payment’, ‘token=’ . $this->session->data[‘token’], ‘SSL’));

可以改成類別頁
$this->response->redirect($this->url->link(‘extension/extension’, ‘token=’ . $this->session->data[‘token’] . ‘&type=shipping’, $this->ssl));//存檔後返回頁-預設是到類別頁
或是本頁
$this->response->redirect($this->url->link(‘extension/shipping/ezship_shipment’, ‘token=’ . $this->session->data[‘token’], $this->ssl));
————————————————————————————–
//存檔按鈕
$data[‘action’] = $this->url->link(‘payment/ezship’, ‘token=’ . $this->session->data[‘token’], ‘SSL’);
//取消按鈕
$data[‘cancel’] = $this->url->link(‘extension/payment’, ‘token=’ . $this->session->data[‘token’], ‘SSL’);
//存檔按鈕
$data[‘action’] = $this->url->link(‘extension/payment/ezship’, ‘token=’ . $this->session->data[‘token’], $this->ssl);
//取消按鈕
$data[‘cancel’] = $this->url->link(‘extension/extension’, ‘token=’ . $this->session->data[‘token’] . ‘&type=payment’, $this->ssl);

———————————–
#語言圖標修正
———————————–
c:\Users\suffi\Desktop\超商取貨付款插件\admin\view\template\extension\payment\ezship.tpl

/.png”
原版寫法

發佈於

智付寶Pay2go後台退款模組退款功能

程式開發日誌-兼碼農打廣告
2017/08/25 耗時1周測試3天,開發完成
—————————————-
#智付寶Pay2go_後台退款模組退款功能
退款功能-詳細說明
—————————————-
原版OPENCART-的退換貨單列表-其實只是個留言板功能,完全不會觸發真的信用卡退款
添加-PAY2GO 信用卡刷卡-退款功能
1.可-全額退款
2.可-部分退款(退款金額由商家自行輸入)
3.部分退款-之執行2次,3次,成立
4.連線至PAY2GO查詢訂單退款狀態功能
5.退款完成時,修改訂單狀態為退款,並增加1筆退款紀錄-
於顯示-訂單列表-增加此功能
於顯示-退換貨單列表-增加此功能
(交易金額100元,第1次退10元,第2次退20元這方法也是成立,但上筆退款狀態未處理完成時,送出下一筆無效)
經測試退款狀態由1變3要等到隔天早上10:00
退款狀態依不同情況,設定值代表下列意含
0=未退款
1=等待提送退款至收單機構
2=退款處理中
3=退款完成
—————————————-
#碼農自介
—————————————-
貧民出身,是臺灣該國中一小撮研究開源購物車
OPENCART和投票系統的人物,如果您需要中文化,破解插件,或修改客製化,除原作者外全臺灣你找不到比我會修改的人才
歡迎了解詳情網址http://blog.bkk.tw

發佈於

商品放入購物車時閃爍數字效果

頁頭購物車有商品加入時,例如我已買了2個商品,購物車圖案就會顯示一個醒目的數字2

作法

—————————————-
#OPENCART 2.3 商品放入購物車時閃爍數字效果
—————————————-
D:\wamp\www\o03\catalog\controller\checkout\cart.php 只有增加時才提示
394行 $json[‘vou’] = $this->cart->countProducts();//自加商品數量

common.js 4個地方
$(‘#cart > button’).html(‘<span id=”cart-total”><i class=”fa fa-shopping-cart”></i> ‘ + json[‘total’] + ‘</span>’);
$(‘#cart > button’).html(‘<span id=”cart-total”><i class=”fa fa-shopping-cart”></i><span class=”blink badge2 badge-red rounded-x”>’ + json[‘vou’] + ‘</span> ‘ + json[‘total’] + ‘</span>’);

CSS
/*購物車閃爍效果*/
span.badge2 {
min-width: 10px;
padding: 3px 7px;
font-size: 12px;
font-weight: 700;
line-height: 1;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: middle;
}
span.badge2 {
top: -5px;
left: -15px;
position: absolute;
}
span.badge-red {background: #e74c3c;}
.rounded-x {border-radius: 50% !important;}
/*閃爍動畫*/
.blink {
animation-duration: 1s;
animation-name: blink;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: ease-in-out;
}
@-o-keyframes blink
{
0% {opacity: 1}
50% {opacity: 0.3}
100% {opacity: 1}
}
@-ms-keyframes blink
{
0% {opacity: 1}
50% {opacity: 0.3}
100% {opacity: 1}
}
@-moz-keyframes blink
{
0% {opacity: 1}
50% {opacity: 0.3}
100% {opacity: 1}
}
@-webkit-keyframes blink
{
0% {opacity: 1}
50% {opacity: 0.3}
100% {opacity: 1}
}