## 搭建wordpress
1,先搭建好wordpress,基本設置好
2,開啟Log 和 debug功能,準備好開發了。
```
config.php 設置:
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WPS_DEBUG', true );
php.ini 設置:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
```
參考[A Complete Guide to WordPress Debugging (Enable WP\_DEBUG + Other Tools) (kinsta.com)](https://kinsta.com/blog/wordpress-debug/)

```
查看log,debug的地方:
1,管理后臺:/wp-admin/admin.php?page=wc-status
2,寶塔的服務器錯誤日志
3,/wp-content->debug.log
```
3,ssl證書和https,必須的。
[阿里云ssl證書](https://help.aliyun.com/document_detail/98574.html?spm=5176.14113079.help.dexternal.3e473effm7uIWd#concept-wxz-3xn-yfb)
4,基本wordpress功能學習,最基礎的知識推薦看《[阿樹](https://www.ashuwp.com/courses)》,深入淺出了解,建議看[wordpress大學](https://www.wpdaxue.com/tutorials)
4.1, WooCommerce 基本類
[Classes in WooCommerce - WooCommerce](https://woocommerce.com/document/class-reference/)
```
WC_Product
WC_Customer
WC_Cart
```
4.2, rest-api
[WooCommerce REST API - WooCommerce](https://woocommerce.com/document/woocommerce-rest-api/)
5,程序員需要基本了解客戶基本需求,看看《 [60分及格的獨立站]( https://www.chuhaibiji.com/18782/) 》
6,安裝在服務器的情況下可能的問題:[解決線上不能操作文件權限問題](https://blog.csdn.net/aliveqf/article/details/70178503)
*****
*****
## 安裝woocommerce插件:
1,直接從后臺插件市場安裝woocommerce,或者上傳插件文件到plugin
注意:可能出現Google Listings and Ads插件不能安裝問題,先跳過它。
2,選擇模板 storefront 安裝
3,創建一個商品作為測試一下功能
4,導入商品數據方便測試,[參考](https://woocommerce.com/document/importing-woocommerce-sample-data/) ,路徑在 wordpress\wp-content\plugins\woocommerce\sample-data
5,觀察和熟悉各種商品類型,都是很重要
* **Simple**?– covers the vast majority of any products you may sell. Simple products are shipped and have no options. For example, a book.
* **Grouped**?– a collection of related products that?can be purchased individually and only consist of simple products. For example, a set of six drinking glasses.
* **External** or **Affiliate**?– one that you list and describe on your website but is sold elsewhere.
* **Variable**?– a product with variations, each of which may have a different SKU, price, stock option, etc. For example, a t-shirt available in different colors and/or sizes.
*****
*****
## 開發環境的注意:
1,關閉卡慢資源(Gravatar, google font 等),wordpress是國際化的開源軟件,所以國內環境需要適應一下。參考:[wordpress頁面訪問太慢?教你3招優化性能 - 簡書 (jianshu.com)](https://www.jianshu.com/p/336d9a964404)
2,運行起來看看有沒有問題,支付方式可以選擇銀行轉賬,或者checkout測試,完成整個支付購買流程。 注意要配置好SMTP發郵件,不然會報錯。
> - I noticed some other similar 504 errors on forums relating to mail, which I thought would make sense based on the login and ordering with emails firing.
I disabled woocommerce email notifcations, the orders now complete and show client side.
3,SMTP:
推薦插件 https://wordpress.org/plugins/easy-wp-smtp/

郵件日志記錄插件:
[WP Mail Logging – WordPress plugin | WordPress.org](https://wordpress.org/plugins/wp-mail-logging/)

4,(選)性能監控插件,[query-monitor](https://wordpress.org/plugins/query-monitor/) 插件,[教程](https://kinsta.com/blog/query-monitor/)
5,(選) https://tideways.com/ 性能監控服務
6, New relic ,最著名的性能監控。