laybuy-settings.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit;
  4. }
  5. # Process Region-based Assets
  6. $assets = include 'assets.php';
  7. $currency = strtolower(get_woocommerce_currency());
  8. if (!empty($assets[$currency])) {
  9. $region_assets = $assets[$currency];
  10. } else {
  11. $region_assets = $assets['nzd'];
  12. }
  13. $product_page_asset = $region_assets['product_page'];
  14. $ctg_page_asset = $region_assets['category_page'];
  15. $cart_page_asset = $region_assets['cart_page'];
  16. $checkout_page_asset = $region_assets['checkout_page'];
  17. $settings = array(
  18. 'enabled' => array(
  19. 'title' => __( 'Enable/Disable', 'woo_laybuy' ),
  20. 'type' => 'checkbox',
  21. 'label' => __( 'Enable Laybuy', 'woo_laybuy' ),
  22. 'default' => 'no'
  23. ),
  24. 'title' => array(
  25. 'title' => __( 'Title', 'woo_laybuy' ),
  26. 'type' => 'text',
  27. 'description' => __( 'This is the title for this payment method. The customer will see this during checkout.', 'woo_laybuy' ),
  28. 'default' => __( 'Laybuy', 'woo_laybuy' ),
  29. 'desc_tip' => true,
  30. ),
  31. 'environment' => array(
  32. 'title' => __( 'Environment', 'woo_laybuy' ),
  33. 'type' => 'select',
  34. 'description' => __( 'Select the sandbox environment for testing purposes only.', 'woo_laybuy' ),
  35. 'default' => 'production',
  36. 'options' => array(
  37. 'sandbox' => __( 'Sandbox', 'woo_laybuy' ),
  38. 'production' => __( 'Production', 'woo_laybuy' )
  39. ),
  40. 'desc_tip' => true,
  41. ),
  42. 'currency' => array(
  43. 'title' => __( 'Default Currency' , 'woo_laybuy' ),
  44. 'type' => 'multiselect',
  45. 'options' => array(
  46. 'NZD' => __( 'New Zealand Dollars', 'woo_laybuy' ),
  47. 'AUD' => __( 'Australian Dollars', 'woo_laybuy' ),
  48. 'GBP' => __( 'Great British Pounds', 'woo_laybuy' ),
  49. 'USD' => __( 'United States Dollar', 'woo_laybuy' ),
  50. ),
  51. 'label' => __( 'Supported currencies', 'woo_laybuy' ),
  52. 'class' => 'currency-select',
  53. 'default' => 'NZD',
  54. ),
  55. 'global' => array(
  56. 'title' => __( 'Laybuy Global' , 'woo_laybuy' ),
  57. 'type' => 'checkbox',
  58. 'label' => __( 'Enable', 'woo_laybuy' ),
  59. 'default' => 'yes'
  60. ),
  61. // NZD
  62. "sandbox_NZD_merchant_id" => array(
  63. 'title' => __("NZD Merchant ID (sandbox)", 'woo_laybuy'),
  64. 'type' => 'text',
  65. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  66. 'default' => '',
  67. 'desc_tip' => TRUE,
  68. 'label_class' => array('credentials-label'),
  69. ),
  70. "sandbox_NZD_api_key" => array(
  71. 'title' => __("NZD API Key (sandbox)", 'woo_laybuy'),
  72. 'type' => 'text',
  73. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  74. 'default' => '',
  75. 'desc_tip' => TRUE,
  76. ),
  77. "production_NZD_merchant_id" => array(
  78. 'title' => __("NZD Merchant ID (production)", 'woo_laybuy'),
  79. 'type' => 'text',
  80. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  81. 'default' => '',
  82. 'desc_tip' => TRUE,
  83. ),
  84. "production_NZD_api_key" => array(
  85. 'title' => __("NZD API Key (production)", 'woo_laybuy'),
  86. 'type' => 'text',
  87. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  88. 'default' => '',
  89. 'desc_tip' => TRUE,
  90. ),
  91. // AUD
  92. "sandbox_AUD_merchant_id" => array(
  93. 'title' => __("AUD Merchant ID (sandbox)", 'woo_laybuy'),
  94. 'type' => 'text',
  95. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  96. 'default' => '',
  97. 'desc_tip' => TRUE,
  98. ),
  99. "sandbox_AUD_api_key" => array(
  100. 'title' => __("AUD API Key (sandbox)", 'woo_laybuy'),
  101. 'type' => 'text',
  102. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  103. 'default' => '',
  104. 'desc_tip' => TRUE,
  105. ),
  106. "production_AUD_merchant_id" => array(
  107. 'title' => __("AUD Merchant ID (production)", 'woo_laybuy'),
  108. 'type' => 'text',
  109. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  110. 'default' => '',
  111. 'desc_tip' => TRUE,
  112. ),
  113. "production_AUD_api_key" => array(
  114. 'title' => __("AUD API Key (production)", 'woo_laybuy'),
  115. 'type' => 'text',
  116. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  117. 'default' => '',
  118. 'desc_tip' => TRUE,
  119. ),
  120. // GBP
  121. "sandbox_GBP_merchant_id" => array(
  122. 'title' => __("GBP Merchant ID (sandbox)", 'woo_laybuy'),
  123. 'type' => 'text',
  124. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  125. 'default' => '',
  126. 'desc_tip' => TRUE,
  127. ),
  128. "sandbox_GBP_api_key" => array(
  129. 'title' => __("GBP API Key (sandbox)", 'woo_laybuy'),
  130. 'type' => 'text',
  131. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  132. 'default' => '',
  133. 'desc_tip' => TRUE,
  134. ),
  135. "production_GBP_merchant_id" => array(
  136. 'title' => __("GBP Merchant ID (production)", 'woo_laybuy'),
  137. 'type' => 'text',
  138. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  139. 'default' => '',
  140. 'desc_tip' => TRUE,
  141. ),
  142. "production_GBP_api_key" => array(
  143. 'title' => __("GBP API Key (production)", 'woo_laybuy'),
  144. 'type' => 'text',
  145. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  146. 'default' => '',
  147. 'desc_tip' => TRUE,
  148. ),
  149. // USD
  150. "sandbox_USD_merchant_id" => array(
  151. 'title' => __("USD Merchant ID (sandbox)", 'woo_laybuy'),
  152. 'type' => 'text',
  153. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  154. 'default' => '',
  155. 'desc_tip' => TRUE,
  156. ),
  157. "sandbox_USD_api_key" => array(
  158. 'title' => __("USD API Key (sandbox)", 'woo_laybuy'),
  159. 'type' => 'text',
  160. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  161. 'default' => '',
  162. 'desc_tip' => TRUE,
  163. ),
  164. "production_USD_merchant_id" => array(
  165. 'title' => __("USD Merchant ID (production)", 'woo_laybuy'),
  166. 'type' => 'text',
  167. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  168. 'default' => '',
  169. 'desc_tip' => TRUE,
  170. ),
  171. "production_USD_api_key" => array(
  172. 'title' => __("USD API Key (production)", 'woo_laybuy'),
  173. 'type' => 'text',
  174. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  175. 'default' => '',
  176. 'desc_tip' => TRUE,
  177. ),
  178. // Global
  179. "sandbox_global_merchant_id" => array(
  180. 'title' => __("Global Merchant ID", 'woo_laybuy'),
  181. 'type' => 'text',
  182. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  183. 'default' => '',
  184. 'desc_tip' => TRUE,
  185. ),
  186. "sandbox_global_api_key" => array(
  187. 'title' => __("Global API Key", 'woo_laybuy'),
  188. 'type' => 'text',
  189. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  190. 'default' => '',
  191. 'desc_tip' => TRUE,
  192. ),
  193. "production_global_merchant_id" => array(
  194. 'title' => __("Global Merchant ID", 'woo_laybuy'),
  195. 'type' => 'text',
  196. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  197. 'default' => '',
  198. 'desc_tip' => TRUE,
  199. ),
  200. "production_global_api_key" => array(
  201. 'title' => __("Global API Key", 'woo_laybuy'),
  202. 'type' => 'text',
  203. 'description' => __('This will be supplied by Laybuy.com', 'woo_laybuy'),
  204. 'default' => '',
  205. 'desc_tip' => TRUE,
  206. ),
  207. );
  208. if ($this->is_plus()) {
  209. $settings['NZD_pay_limit_min'] = array(
  210. 'title' => __("Limit Min [NZD]", 'woo_laybuy'),
  211. 'type' => 'text',
  212. 'description' => __('Min limit for the payments in NZD', 'woo_laybuy'),
  213. 'default' => '0.06',
  214. 'desc_tip' => TRUE,
  215. );
  216. $settings['NZD_pay_limit_max'] = array(
  217. 'title' => __("Limit Max [NZD]", 'woo_laybuy'),
  218. 'type' => 'text',
  219. 'description' => __('Max limit for the payments in NZD', 'woo_laybuy'),
  220. 'default' => '1500',
  221. 'desc_tip' => TRUE,
  222. );
  223. $settings['AUD_pay_limit_min'] = array(
  224. 'title' => __("Limit Min [AUD]", 'woo_laybuy'),
  225. 'type' => 'text',
  226. 'description' => __('Min limit for the payments in AUD', 'woo_laybuy'),
  227. 'default' => '0.06',
  228. 'desc_tip' => TRUE,
  229. );
  230. $settings['AUD_pay_limit_max'] = array(
  231. 'title' => __("Limit Max [AUD]", 'woo_laybuy'),
  232. 'type' => 'text',
  233. 'description' => __('Max limit for the payments in AUD', 'woo_laybuy'),
  234. 'default' => '1200',
  235. 'desc_tip' => TRUE,
  236. );
  237. $settings['GBP_pay_limit_min'] = array(
  238. 'title' => __("Limit Min [GBP]", 'woo_laybuy'),
  239. 'type' => 'text',
  240. 'description' => __('Min limit for the payments in GBP', 'woo_laybuy'),
  241. 'default' => '0.06',
  242. 'desc_tip' => TRUE,
  243. );
  244. $settings['GBP_pay_limit_max'] = array(
  245. 'title' => __("Limit Max [GBP]", 'woo_laybuy'),
  246. 'type' => 'text',
  247. 'description' => __('Max limit for the payments in GBP', 'woo_laybuy'),
  248. 'default' => '720',
  249. 'desc_tip' => TRUE,
  250. );
  251. $settings['USD_pay_limit_min'] = array(
  252. 'title' => __("Limit Min [USD]", 'woo_laybuy'),
  253. 'type' => 'text',
  254. 'description' => __('Min limit for the payments in USD', 'woo_laybuy'),
  255. 'default' => '0.06',
  256. 'desc_tip' => TRUE,
  257. );
  258. $settings['USD_pay_limit_max'] = array(
  259. 'title' => __("Limit Max [USD]", 'woo_laybuy'),
  260. 'type' => 'text',
  261. 'description' => __('Max limit for the payments in USD', 'woo_laybuy'),
  262. 'default' => '1200',
  263. 'desc_tip' => TRUE,
  264. );
  265. }
  266. $settings['debug'] = array(
  267. 'title' => __('Debug', 'woo_laybuy'),
  268. 'label' => __('Enable verbose debug logging', 'woo_laybuy'),
  269. 'type' => 'checkbox',
  270. 'description' =>
  271. __( 'The Laybuy log is in the ', 'woo_laybuy' ) .
  272. '<code>wc-logs</code>' .
  273. __( ' folder, which is accessible from the ', 'woo_laybuy' ) .
  274. '<a href="' . admin_url( 'admin.php?page=wc-status&tab=logs' ) . '">' .
  275. __( 'WooCommerce System Status', 'woo_laybuy' ) .
  276. '</a>' .
  277. __( ' page.', 'woo_laybuy' ),
  278. 'default' => 'no',
  279. );
  280. $settings['presentational_customisation_title'] = array(
  281. 'title' => __( 'Customisation', 'woo_laybuy' ),
  282. 'type' => 'title',
  283. 'description' => __( 'Please feel free to customise the presentation of the Laybuy elements below to suit the individual needs of your web store.</p><p><em>Note: Advanced customisations may require the assistance of your web development team.</em>', 'woo_laybuy' )
  284. );
  285. $product_types = [];
  286. foreach (wc_get_product_types() as $value => $label) {
  287. $product_types[$value] = $label;
  288. }
  289. $settings['product_types'] = array(
  290. 'title' => __( 'Displayed for Product Types', 'woo_laybuy' ),
  291. 'type' => 'multiselect',
  292. 'description' => __( 'Select product types for which Laybuy widget is displayed', 'woo_laybuy' ),
  293. 'options' => $product_types,
  294. 'custom_attributes' => array(
  295. 'size' => '4'
  296. ),
  297. 'default' => array_keys($product_types),
  298. );
  299. $settings += array(
  300. 'show_info_on_category_pages' => array(
  301. 'title' => __( 'Payment Info on Category Pages', 'woo_laybuy' ),
  302. 'label' => __( 'Enable', 'woo_laybuy' ),
  303. 'type' => 'checkbox',
  304. 'description' => __( 'Enable to display Laybuy elements on category pages', 'woo_laybuy' ),
  305. 'default' => 'yes'
  306. ),
  307. 'category_pages_info_text' => array(
  308. 'type' => 'wysiwyg',
  309. 'default' => $ctg_page_asset,
  310. 'description' => __( 'Use [AMOUNT] to insert the calculated instalment amount. Use [OF_OR_FROM] to insert "from" if the product\'s price is variable, or "of" if it is static.', 'woo_laybuy' )
  311. ),
  312. 'show_info_on_product_pages' => array(
  313. 'title' => __( 'Payment Info on Individual Product Pages', 'woo_laybuy' ),
  314. 'label' => __( 'Enable', 'woo_laybuy' ),
  315. 'type' => 'checkbox',
  316. 'description' => __( 'Enable to display Laybuy elements on individual product pages', 'woo_laybuy' ),
  317. 'default' => 'yes'
  318. ),
  319. 'product_pages_info_text' => array(
  320. 'type' => 'wysiwyg',
  321. 'default' => $product_page_asset,
  322. 'description' => __( 'Use [AMOUNT] to insert the calculated instalment amount. Use [OF_OR_FROM] to insert "from" if the product\'s price is variable, or "of" if it is static.', 'woo_laybuy' )
  323. ),
  324. 'price_breakdown_option_product_page_position' => array(
  325. 'title' => __('Product Price breakdown Position', 'woo_laybuy'),
  326. 'type' => 'select',
  327. 'description' => 'Select where on the Product page you would like the breakdown to display, see <a href="https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/" target="_blank">here</a> for a visual guide',
  328. 'default' => 'disable',
  329. 'options' => array(
  330. 'woocommerce_single_product_summary' => __('woocommerce_single_product_summary' ),
  331. 'woocommerce_before_add_to_cart_form' => __('woocommerce_before_add_to_cart_form' ),
  332. 'woocommerce_before_variations_form' => __('woocommerce_before_variations_form' ),
  333. 'woocommerce_before_add_to_cart_button' => __('woocommerce_before_add_to_cart_button' ),
  334. 'woocommerce_before_single_variation' => __('woocommerce_before_single_variation' ),
  335. 'woocommerce_single_variation' => __('woocommerce_single_variation' ),
  336. 'woocommerce_after_single_variation' => __('woocommerce_after_single_variation' ),
  337. 'woocommerce_after_add_to_cart_button' => __('woocommerce_after_add_to_cart_button' ),
  338. 'woocommerce_after_add_to_cart_form' => __('woocommerce_after_add_to_cart_form' ),
  339. 'woocommerce_product_meta_start' => __('woocommerce_product_meta_start' ),
  340. 'woocommerce_product_meta_end' => __('woocommerce_product_meta_end' ),
  341. ),
  342. ),
  343. 'product_price_breakdown_hook_priority' => [
  344. 'title' => __("Product Price Breakdown Hook Priority", 'woo_laybuy'),
  345. 'type' => 'text',
  346. 'description' => __('Choose hook priority for the product price breakdown hook. Default is 11.', 'woo_laybuy'),
  347. 'default' => 11,
  348. 'desc_tip' => false,
  349. ],
  350. 'checkout_page_info_text' => array(
  351. 'title' => __( 'Payment Info on Checkout Page', 'woo_laybuy' ),
  352. 'type' => 'wysiwyg',
  353. 'default' => $checkout_page_asset,
  354. 'description' => __( 'Use [AMOUNT] to insert the calculated instalment amount. In this case, the instalment amount will be calculated based on the grand total of the cart, including tax and shipping.', 'woo_laybuy' )
  355. ),
  356. 'show_info_on_cart_page' => array(
  357. 'title' => __( 'Payment Info on Cart Page', 'woo_laybuy' ),
  358. 'label' => __( 'Enable', 'woo_laybuy' ),
  359. 'type' => 'checkbox',
  360. 'description' => __( 'Enable to display Laybuy elements on the cart page', 'woo_laybuy' ),
  361. 'default' => 'yes'
  362. ),
  363. 'cart_page_info_text' => array(
  364. 'type' => 'textarea',
  365. 'default' => $cart_page_asset,
  366. 'description' => __( 'Use [AMOUNT] to insert the calculated instalment amount. In this case, the instalment amount will be calculated based on the grand total of the cart, including tax and shipping.', 'woo_laybuy' )
  367. ),
  368. 'laybuy_fontsize_in_breakdowns' => array(
  369. 'title' => __('Font Size Breakdowns', 'woo_laybuy'),
  370. 'type' => 'select',
  371. 'default' => '12px',
  372. 'description' => __('Select the Font Size in the breakdowns', 'woo_laybuy'),
  373. 'options' => array(
  374. '10px' => __('10px', 'woo_laybuy'),
  375. '12px' => __('12px', 'woo_laybuy'),
  376. '14px' => __('14px', 'woo_laybuy'),
  377. '16px' => __('16px', 'woo_laybuy'),
  378. '18px' => __('18px', 'woo_laybuy'),
  379. '20px' => __('20px', 'woo_laybuy'),
  380. )
  381. ),
  382. 'laybuy_logo_theme' => array(
  383. 'title' => __('Laybuy Logo Theme', 'woo_laybuy'),
  384. 'type' => 'select',
  385. 'default' => 'White',
  386. 'description' => __('Select the Laybuy logo theme in the breakdowns', 'woo_laybuy'),
  387. 'options' => array(
  388. 'white' => __('White', 'woo_laybuy'),
  389. 'dark' => __('Dark', 'woo_laybuy'),
  390. )
  391. ),
  392. 'laybuy_currency_prefix_in_breakdowns' => array(
  393. 'title' => __('Show Currency code in Breakdowns', 'woo_laybuy'),
  394. 'type' => 'checkbox',
  395. 'default' => 'yes',
  396. 'description' => __('Show the currency code (ie NZD) in the breakdowns', 'woo_laybuy'),
  397. ),
  398. 'laybuy_page_enabled' => array(
  399. 'title' => __('Laybuy Page', 'woo_laybuy'),
  400. 'label' => __( 'Enable', 'woo_laybuy' ),
  401. 'type' => 'checkbox',
  402. 'default' => 'yes',
  403. 'description' => __('Enable /laybuy info page', 'woo_laybuy'),
  404. ),
  405. 'laybuy_wide_layout_setting' => array(
  406. 'title' => __('Set the laybuy checkout to wide'),
  407. 'type' => 'checkbox',
  408. 'default' => 'no',
  409. 'description' => __('Use this to display the Laybuy process in a single row, instead of two rows. Best suited for wide/single column checkout themes.', 'woo_laybuy'),
  410. ),
  411. 'laybuy_compatibility_mode' => array(
  412. 'title' => __('Compatibility Mode'),
  413. 'type' => 'checkbox',
  414. 'default' => 'no',
  415. 'description' => __('Use this mode only if experiencing challenges with the display of order data within the WooCommerce admin views for Laybuy orders.', 'woo_laybuy'),
  416. ),
  417. 'laybuy_geolocate_ip' => array(
  418. 'title' => __('Geolocation IP'),
  419. 'label' => __( 'Enable', 'woo_laybuy' ),
  420. 'type' => 'checkbox',
  421. 'default' => 'no',
  422. 'description' => __('Enable geolocation to display Laybuy payment method only for supported countries (NZ, AU, GB).', 'woo_laybuy'),
  423. ),
  424. 'laybuy_price_breakdown_out_of_stock' => array(
  425. 'title' => __('Price breakdown for "out of stock" products'),
  426. 'label' => __( 'Enable', 'woo_laybuy' ),
  427. 'type' => 'checkbox',
  428. 'default' => 'no',
  429. 'description' => __('Price breakdown snippet will appear on products that are "out of stock"', 'woo_laybuy'),
  430. ),
  431. 'laybuy_billing_phone_field' => array(
  432. 'title' => __("Billing Phone Field Name", 'woo_laybuy'),
  433. 'type' => 'text',
  434. 'description' => __('Override for custom checkout phone field name', 'woo_laybuy'),
  435. 'default' => 'billing_phone',
  436. ),
  437. 'laybuy_advance_setting' => array(
  438. 'title' => __('Developer Mode (Advanced)', 'woo_laybuy'),
  439. 'type' => 'checkbox',
  440. 'default' => 'no',
  441. 'description' => __('This is only for developers, be careful with this setting. You should not need to use this.', 'woo_laybuy'),
  442. ),
  443. 'laybuy_send_support_request' => array(
  444. 'title' => __('', 'woo_laybuy'),
  445. 'type' => 'support_request_btn',
  446. 'desc_tip' => false,
  447. 'description' => __('Submit email support request to Laybuy.', 'woo_laybuy'),
  448. ),
  449. );
  450. return apply_filters('woocommerce_laybuy_settings', $settings);