Changeset 3740659
- Timestamp:
- 10/12/2026 07:03:00 AM (11 days ago)
- Location:
- weareplanet
- Files:
-
- 24 deleted
- 96 edited
- 1 copied
-
tags/3.4.9 (copied) (copied from weareplanet/trunk )
-
tags/3.4.9/changelog.txt (modified) (4 diffs)
-
tags/3.4.9/docs/en/documentation.html (modified) (2 diffs)
-
tags/3.4.9/includes/admin/class-wc-weareplanet-admin-refund.php (modified) (2 diffs)
-
tags/3.4.9/includes/admin/class-wc-weareplanet-admin-settings-page.php (modified) (11 diffs)
-
tags/3.4.9/includes/admin/class-wc-weareplanet-admin-transaction.php (modified) (1 diff)
-
tags/3.4.9/includes/admin/class-wc-weareplanet-admin.php (modified) (5 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-blocks-support.php (modified) (7 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-commands.php (modified) (1 diff)
-
tags/3.4.9/includes/class-wc-weareplanet-customer-document.php (modified) (2 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-email.php (modified) (8 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-gateway.php (modified) (14 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-helper.php (modified) (22 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-migration.php (modified) (28 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-order-reference.php (modified) (1 diff)
-
tags/3.4.9/includes/class-wc-weareplanet-order-status-adapter.php (modified) (24 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-return-handler.php (modified) (1 diff)
-
tags/3.4.9/includes/class-wc-weareplanet-subscription-gateway.php (modified) (7 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-subscription.php (modified) (8 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-unique-id.php (modified) (6 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-webhook-handler.php (modified) (2 diffs)
-
tags/3.4.9/includes/class-wc-weareplanet-zero-gateway.php (modified) (10 diffs)
-
tags/3.4.9/includes/entity/class-wc-weareplanet-entity-attribute-options.php (modified) (2 diffs)
-
tags/3.4.9/includes/entity/class-wc-weareplanet-entity-method-configuration.php (modified) (2 diffs)
-
tags/3.4.9/includes/entity/class-wc-weareplanet-entity-refund-job.php (modified) (2 diffs)
-
tags/3.4.9/includes/entity/class-wc-weareplanet-entity-token-info.php (modified) (2 diffs)
-
tags/3.4.9/includes/entity/class-wc-weareplanet-entity-transaction-info.php (modified) (4 diffs)
-
tags/3.4.9/includes/entity/class-wc-weareplanet-entity-void-job.php (modified) (8 diffs)
-
tags/3.4.9/includes/packages/gift-card/class-wc-weareplanet-packages-gift-card.php (modified) (1 diff)
-
tags/3.4.9/includes/provider/class-wc-weareplanet-provider-language.php (modified) (1 diff)
-
tags/3.4.9/includes/service/class-wc-weareplanet-service-line-item.php (modified) (20 diffs)
-
tags/3.4.9/includes/service/class-wc-weareplanet-service-token.php (modified) (1 diff)
-
tags/3.4.9/includes/service/class-wc-weareplanet-service-transaction.php (modified) (13 diffs)
-
tags/3.4.9/includes/service/class-wc-weareplanet-service-webhook.php (modified) (4 diffs)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-abstract.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-delivery-indication.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-manual-task.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-method-configuration.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-order-related-abstract.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-refund.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-token-version.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-token.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-transaction-completion.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-transaction-invoice.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-transaction-void.php (deleted)
-
tags/3.4.9/includes/webhook/class-wc-weareplanet-webhook-transaction.php (deleted)
-
tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-delivery-indication-strategy.php (modified) (2 diffs)
-
tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-refund-strategy.php (modified) (2 diffs)
-
tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-completion-strategy.php (modified) (2 diffs)
-
tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-invoice-strategy.php (modified) (2 diffs)
-
tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-strategy.php (modified) (14 diffs)
-
tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-void-strategy.php (modified) (2 diffs)
-
tags/3.4.9/readme.txt (modified) (3 diffs)
-
tags/3.4.9/views/admin-notices/subscription-plugin-deactivate.php (modified) (1 diff)
-
tags/3.4.9/views/admin-settings/html-admin-page-order-statuses.php (modified) (4 diffs)
-
tags/3.4.9/weareplanet-sdk/composer.json (modified) (1 diff)
-
tags/3.4.9/weareplanet-sdk/lib/ApiClient.php (modified) (2 diffs)
-
tags/3.4.9/weareplanet-sdk/lib/Configuration.php (modified) (2 diffs)
-
tags/3.4.9/weareplanet-sdk/lib/Model/AbstractWebhookListenerUpdate.php (modified) (6 diffs)
-
tags/3.4.9/weareplanet-sdk/test/ApiClientTest.php (modified) (1 diff)
-
tags/3.4.9/weareplanet.php (modified) (31 diffs)
-
trunk/changelog.txt (modified) (4 diffs)
-
trunk/docs/en/documentation.html (modified) (2 diffs)
-
trunk/includes/admin/class-wc-weareplanet-admin-refund.php (modified) (2 diffs)
-
trunk/includes/admin/class-wc-weareplanet-admin-settings-page.php (modified) (11 diffs)
-
trunk/includes/admin/class-wc-weareplanet-admin-transaction.php (modified) (1 diff)
-
trunk/includes/admin/class-wc-weareplanet-admin.php (modified) (5 diffs)
-
trunk/includes/class-wc-weareplanet-blocks-support.php (modified) (7 diffs)
-
trunk/includes/class-wc-weareplanet-commands.php (modified) (1 diff)
-
trunk/includes/class-wc-weareplanet-customer-document.php (modified) (2 diffs)
-
trunk/includes/class-wc-weareplanet-email.php (modified) (8 diffs)
-
trunk/includes/class-wc-weareplanet-gateway.php (modified) (14 diffs)
-
trunk/includes/class-wc-weareplanet-helper.php (modified) (22 diffs)
-
trunk/includes/class-wc-weareplanet-migration.php (modified) (28 diffs)
-
trunk/includes/class-wc-weareplanet-order-reference.php (modified) (1 diff)
-
trunk/includes/class-wc-weareplanet-order-status-adapter.php (modified) (24 diffs)
-
trunk/includes/class-wc-weareplanet-return-handler.php (modified) (1 diff)
-
trunk/includes/class-wc-weareplanet-subscription-gateway.php (modified) (7 diffs)
-
trunk/includes/class-wc-weareplanet-subscription.php (modified) (8 diffs)
-
trunk/includes/class-wc-weareplanet-unique-id.php (modified) (6 diffs)
-
trunk/includes/class-wc-weareplanet-webhook-handler.php (modified) (2 diffs)
-
trunk/includes/class-wc-weareplanet-zero-gateway.php (modified) (10 diffs)
-
trunk/includes/entity/class-wc-weareplanet-entity-attribute-options.php (modified) (2 diffs)
-
trunk/includes/entity/class-wc-weareplanet-entity-method-configuration.php (modified) (2 diffs)
-
trunk/includes/entity/class-wc-weareplanet-entity-refund-job.php (modified) (2 diffs)
-
trunk/includes/entity/class-wc-weareplanet-entity-token-info.php (modified) (2 diffs)
-
trunk/includes/entity/class-wc-weareplanet-entity-transaction-info.php (modified) (4 diffs)
-
trunk/includes/entity/class-wc-weareplanet-entity-void-job.php (modified) (8 diffs)
-
trunk/includes/packages/gift-card/class-wc-weareplanet-packages-gift-card.php (modified) (1 diff)
-
trunk/includes/provider/class-wc-weareplanet-provider-language.php (modified) (1 diff)
-
trunk/includes/service/class-wc-weareplanet-service-line-item.php (modified) (20 diffs)
-
trunk/includes/service/class-wc-weareplanet-service-token.php (modified) (1 diff)
-
trunk/includes/service/class-wc-weareplanet-service-transaction.php (modified) (13 diffs)
-
trunk/includes/service/class-wc-weareplanet-service-webhook.php (modified) (4 diffs)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-abstract.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-delivery-indication.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-manual-task.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-method-configuration.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-order-related-abstract.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-refund.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-token-version.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-token.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-transaction-completion.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-transaction-invoice.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-transaction-void.php (deleted)
-
trunk/includes/webhook/class-wc-weareplanet-webhook-transaction.php (deleted)
-
trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-delivery-indication-strategy.php (modified) (2 diffs)
-
trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-refund-strategy.php (modified) (2 diffs)
-
trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-completion-strategy.php (modified) (2 diffs)
-
trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-invoice-strategy.php (modified) (2 diffs)
-
trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-strategy.php (modified) (14 diffs)
-
trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-void-strategy.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/views/admin-notices/subscription-plugin-deactivate.php (modified) (1 diff)
-
trunk/views/admin-settings/html-admin-page-order-statuses.php (modified) (4 diffs)
-
trunk/weareplanet-sdk/composer.json (modified) (1 diff)
-
trunk/weareplanet-sdk/lib/ApiClient.php (modified) (2 diffs)
-
trunk/weareplanet-sdk/lib/Configuration.php (modified) (2 diffs)
-
trunk/weareplanet-sdk/lib/Model/AbstractWebhookListenerUpdate.php (modified) (6 diffs)
-
trunk/weareplanet-sdk/test/ApiClientTest.php (modified) (1 diff)
-
trunk/weareplanet.php (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
weareplanet/tags/3.4.9/changelog.txt
r3676036 r3740659 963 963 - [Tested Against] PHP SDK 4.8.0 964 964 965 = 3.4. 8- July 22nd 2025 =965 = 3.4.9 - July 22nd 2025 = 966 966 - [Bugfix] Fix class loading order issues 967 967 - [Bugfix] Fix problem with multisite not installing tables when plugin is network activated … … 979 979 - [Hotfix] Rollback to stable version 980 980 981 = 3.4. 8- July 29nd 2025 =981 = 3.4.9 - July 29nd 2025 = 982 982 - [Bugfix] Fix class loading order issues 983 983 - [Bugfix] Fix problem with multisite not installing tables when plugin is network activated … … 992 992 - [Tested Against] PHP SDK 4.8.0 993 993 994 = 3.4. 8- July 30th 2025 =994 = 3.4.9 - July 30th 2025 = 995 995 - [Bugfix] Fix issue with calling a renamed function 996 996 - [Tested Against] PHP 8.2 … … 1115 1115 - [Tested Against] PHP SDK 4.9.1 1116 1116 1117 = 3.4.9 - October 7 2026 = 1118 - [Feature] Tested against Wordpress 7.1.2 1119 - [Bugfix] Fixed issue where translations for payment methods were incorrect 1120 - [Tested Against] PHP 8.4.20 1121 - [Tested Against] Wordpress 7.1.2 1122 - [Tested Against] Woocommerce 11.2.0 1123 - [Tested Against] PHP SDK 4.9.2 1124 -
weareplanet/tags/3.4.9/docs/en/documentation.html
r3676036 r3740659 24 24 </li> 25 25 <li> 26 <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4. 8/">26 <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4.9/"> 27 27 Source 28 28 </a> … … 397 397 <td class="tableblock halign-left valign-top"><p class="tableblock">Device/session ID for fraud prevention during payment. Set/updated by the plugin on the WordPress init hook.</p></td> 398 398 </tr> 399 <tr>400 <td class="tableblock halign-left valign-top"><p class="tableblock"><code>weareplanetNewUi</code></p></td>401 <td class="tableblock halign-left valign-top"><p class="tableblock">Functional</p></td>402 <td class="tableblock halign-left valign-top"><p class="tableblock">Persistent (10 years)</p></td>403 <td class="tableblock halign-left valign-top"><p class="tableblock">WeArePlanet</p></td>404 <td class="tableblock halign-left valign-top"><p class="tableblock">UI-version toggle for the WeArePlanet merchant portal (old vs. new UI). Set automatically on every login based on the user’s stored preference, and can be toggled by the user. HttpOnly, Secure on HTTPS.</p></td>405 </tr>406 399 </tbody> 407 400 </table> </div> -
weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin-refund.php
r3433358 r3740659 146 146 * Executes refund. 147 147 * 148 * @param WC_Order $order wc_order.148 * @param WC_Order $order wc_order. 149 149 * @param WC_Order_Refund $refund refund. 150 150 * @return void … … 279 279 * Creates a new refund job for the given order and refund. 280 280 * 281 * @param WC_Order $order wc_order.282 * @param WC_Order_Refund $refund refund.281 * @param WC_Order $order wc_order. 282 * @param WC_Order_Refund $refund refund. 283 283 * @param \WeArePlanet\Sdk\Model\RefundCreate $refund_create refund_create. 284 284 * @return WC_WeArePlanet_Entity_Refund_Job -
weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin-settings-page.php
r3676036 r3740659 109 109 */ 110 110 protected function get_settings_for_weareplanet_order_statuses_section() { 111 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $hide_save_button is a woocommerce core global used to control settings page ui, therefore we don't rename it 111 112 global $current_section, $hide_save_button; 112 113 $hide_save_button = true; 114 // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound 113 115 return $this->get_order_statuses(); 114 116 } … … 206 208 array( 207 209 'links' => array( 208 'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4. 8/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ),210 'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ), 209 211 'https://www.weareplanet.com/contact/sales' => esc_html__( 'Sign Up', 'woo-weareplanet' ), 210 212 ), … … 268 270 ), 269 271 270 array(271 'title'=> esc_html__( 'Disable Pending Email', 'woo-weareplanet' ),272 'desc'=> esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ),273 'id'=> WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL,274 'type'=> 'checkbox',275 'default' => 'no',276 'css'=> 'min-width:300px;',277 ),272 array( 273 'title' => esc_html__( 'Disable Pending Email', 'woo-weareplanet' ), 274 'desc' => esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ), 275 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 276 'type' => 'checkbox', 277 'default' => 'no', 278 'css' => 'min-width:300px;', 279 ), 278 280 279 281 array( … … 339 341 'desc_tip' => wp_kses_post( 340 342 __( 341 'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.',342 'woo-weareplanet'343 'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.', 344 'woo-weareplanet' 343 345 ) 344 346 ), … … 365 367 ), 366 368 367 array(368 'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ),369 'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ),370 'desc_tip' => esc_html__(371 "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.",372 'woo-weareplanet'373 ),374 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY,375 'type' => 'checkbox',376 'default' => 'yes',377 'css' => 'min-width:300px;',378 ),369 array( 370 'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ), 371 'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ), 372 'desc_tip' => esc_html__( 373 "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.", 374 'woo-weareplanet' 375 ), 376 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY, 377 'type' => 'checkbox', 378 'default' => 'yes', 379 'css' => 'min-width:300px;', 380 ), 379 381 380 382 array( … … 392 394 'title' => esc_html__( 'Order Reference Type', 'woo-weareplanet' ), 393 395 'desc_tip' => esc_html__( 394 'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.',395 'woo-weareplanet'396 'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.', 397 'woo-weareplanet' 396 398 ), 397 399 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ORDER_REFERENCE, … … 440 442 */ 441 443 public function get_order_status_settings() { 442 $settings = [];444 $settings = array(); 443 445 $is_custom_status_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled(); 444 446 … … 454 456 'desc' => esc_html__( 'If enabled, custom statuses (such as Manual Decision) will be used instead of the default WooCommerce statuses.', 'woo-weareplanet' ), 455 457 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING, 456 'type' => 'checkbox',458 'type' => 'checkbox', 457 459 'default' => 'no', 458 'css' => 'min-width:300px;',460 'css' => 'min-width:300px;', 459 461 ); 460 462 … … 475 477 <span class="weareplanet-status-mapping-col-left">%s</span> 476 478 <span class="weareplanet-status-mapping-col-right">%s</span> 477 </div>' 478 , 479 </div>', 479 480 esc_html__( 'WeArePlanet payment status', 'woo-weareplanet' ), 480 481 esc_html__( 'WooCommerce Order Status', 'woo-weareplanet' ) … … 519 520 ); 520 521 521 522 522 return apply_filters( 'weareplanet_custom_order_statuses_settings', $settings ); 523 523 } … … 592 592 'underscore', 593 593 'backbone', 594 'wc-backbone-modal' 594 'wc-backbone-modal', 595 595 ), 596 596 $version, -
weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin-transaction.php
r3463230 r3740659 45 45 * @see: https://woo.com/document/high-performance-order-storage/#section-8 46 46 * @see: https://developer.wordpress.org/reference/hooks/add_meta_boxes/ 47 * @param string $post_type The type of post where the meta box should be added.47 * @param string $post_type The type of post where the meta box should be added. 48 48 * @param WP_Post|WC_Order|null $post_or_order_object The post or order object. 49 49 */ 50 public static function add_meta_box( $post_type = "", $post_or_order_object = null ) {50 public static function add_meta_box( $post_type = '', $post_or_order_object = null ) { 51 51 // WooCommerce is moving the Order information from Post to Order class. For now, we need to support both ways. 52 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order ) ) {52 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order ) ) { 53 53 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof WP_Post ) || empty( $post_or_order_object->ID ) || 'shop_order' != $post_or_order_object->post_type ) { 54 54 return; -
weareplanet/tags/3.4.9/includes/admin/class-wc-weareplanet-admin.php
r3463230 r3740659 245 245 * Remove unwanted order actions 246 246 * 247 * @param array $actions actions.247 * @param array $actions actions. 248 248 * @param WC_Order $order order. 249 249 * @return array … … 389 389 */ 390 390 public function display_attribute_options_edit() { 391 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- read only display function. $_GET['edit'] is a woocommerce admin url param. Nonce is verified in the save handler. 391 392 if ( ! isset( $_GET['edit'] ) ) { 392 393 return; … … 394 395 $edit = absint( $_GET['edit'] ); 395 396 } 397 // phpcs:enable WordPress.Security.NonceVerification.Recommended 396 398 $checked = false; 397 399 $attribute_options = WC_WeArePlanet_Entity_Attribute_Options::load_by_attribute_id( $edit ); … … 407 409 </th> 408 410 <td> 409 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>411 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?> 410 412 <input 411 413 name="weareplanet_attribute_option_send" … … 429 431 <div class="form-field"> 430 432 <label for="weareplanet_attribute_option_send"> 431 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>433 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?> 432 434 <input name="weareplanet_attribute_option_send" id="weareplanet_attribute_option_send" type="checkbox" value="1"> 433 435 <?php esc_html_e( 'Send attribute to WeArePlanet', 'woo-weareplanet' ); ?> -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-blocks-support.php
r3676036 r3740659 1 1 <?php 2 3 2 /** 4 3 * Plugin Name: WeArePlanet … … 58 57 public function get_payment_method_script_handles() { 59 58 $dependencies = array(); 60 $version = '3.4. 8';59 $version = '3.4.9'; 61 60 62 61 wp_register_script( … … 107 106 $update_transaction = isset( $_POST['updateTransaction'] ) ? (bool) sanitize_key( wp_unslash( $_POST['updateTransaction'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing 108 107 $enqueue_portal_scripts = isset( $_POST['enqueuePortalScripts'] ) ? (bool) sanitize_key( wp_unslash( $_POST['enqueuePortalScripts'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing 109 108 110 109 if ( true === $update_transaction ) { 111 110 $transaction_service = WC_WeArePlanet_Service_Transaction::instance(); … … 122 121 123 122 $payment_plugin = array_filter( 124 $payment_gateways,125 fn( $key ) => str_contains( $key, 'weareplanet_' ),126 ARRAY_FILTER_USE_KEY123 $payment_gateways, 124 fn( $key ) => str_contains( $key, 'weareplanet_' ), 125 ARRAY_FILTER_USE_KEY 127 126 ); 128 127 129 128 $payments_list = 130 array_map(131 function ( $payment_gateway ) use ( $available_payment_methods ) {132 $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription();133 $cartTotal = (WC()->cart && WC()->cart->total) ?? 0;134 135 $isPaymentMethodVisibleOnCheckout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && $cartTotal == 0;136 $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID137 ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE138 : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );139 140 if ( !$isPaymentMethodVisibleOnCheckout ) {141 $isPaymentMethodVisibleOnCheckout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cartTotal > 0 || $has_subscription );142 }143 144 return array(145 'name' => $payment_gateway->id,146 'label' => $payment_gateway->get_title(),147 'ariaLabel' => $payment_gateway->get_title(),148 'description' => $payment_gateway->get_description(),149 'configuration_id' => $payment_gateway->get_payment_configuration_id(),150 'integration_mode' => $integration_mode,151 'supports' => $payment_gateway->supports,152 'icon' => $payment_gateway->get_icon(),153 'isActive' => $isPaymentMethodVisibleOnCheckout154 );155 },156 $payment_plugin157 );129 array_map( 130 function ( $payment_gateway ) use ( $available_payment_methods ) { 131 $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription(); 132 $cart_total = ( WC()->cart && WC()->cart->total ) ?? 0; 133 134 $is_payment_method_visible_on_checkout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && 0 === $cart_total; 135 $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID 136 ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE 137 : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ); 138 139 if ( ! $is_payment_method_visible_on_checkout ) { 140 $is_payment_method_visible_on_checkout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cart_total > 0 || $has_subscription ); 141 } 142 143 return array( 144 'name' => $payment_gateway->id, 145 'label' => $payment_gateway->get_title(), 146 'ariaLabel' => $payment_gateway->get_title(), 147 'description' => $payment_gateway->get_description(), 148 'configuration_id' => $payment_gateway->get_payment_configuration_id(), 149 'integration_mode' => $integration_mode, 150 'supports' => $payment_gateway->supports, 151 'icon' => $payment_gateway->get_icon(), 152 'isActive' => $is_payment_method_visible_on_checkout, 153 ); 154 }, 155 $payment_plugin 156 ); 158 157 159 158 return array_values( $payments_list ); 160 } catch ( \Exception $e) {161 return [];159 } catch ( \Exception $e ) { 160 return array(); 162 161 } 163 162 } … … 213 212 */ 214 213 public static function enqueue_portal_scripts() { 215 if ( is_order_received_page() ) return; 214 if ( is_order_received_page() ) { 215 return; 216 } 216 217 217 218 try { … … 219 220 $transaction_service = WC_WeArePlanet_Service_Transaction::instance(); 220 221 $transaction = $transaction_service->get_transaction_from_session(); 221 switch ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) {222 switch ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) { 222 223 case WC_WeArePlanet_Integration::WEAREPLANET_IFRAME: 223 224 $js_url = $transaction_service->get_javascript_url_for_transaction( $transaction ); … … 281 282 [$gateway_result, $transaction] = $payment_method_object->process_payment_transaction( $context->order, $transaction_id, $space_id, true, $transaction_service ); 282 283 283 284 284 $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ); 285 285 $redirect_url = $gateway_result['redirect']; -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-commands.php
r3378673 r3740659 19 19 if ( class_exists( 'WP_CLI' ) && ! class_exists( 'WC_WeArePlanet_Commands' ) ) { 20 20 21 /**22 * Class WC_WeArePlanet_Commands.23 * This class contains custom commands for WeArePlanet.24 *25 * @class WC_WeArePlanet_Commands26 */27 class WC_WeArePlanet_Commands {21 /** 22 * Class WC_WeArePlanet_Commands. 23 * This class contains custom commands for WeArePlanet. 24 * 25 * @class WC_WeArePlanet_Commands 26 */ 27 class WC_WeArePlanet_Commands { 28 28 29 /**30 * Register commands.31 */32 public static function init() {33 WP_CLI::add_command(34 'weareplanet settings init',35 array(36 __CLASS__,37 'settings_init' 38 )39 );40 WP_CLI::add_command(41 'weareplanet webhooks install',42 array(43 __CLASS__,44 'webhooks_install' 45 )46 );47 WP_CLI::add_command(48 'weareplanet payment-methods sync',49 array(50 __CLASS__,51 'payment_methods_sync' 52 )53 );54 }29 /** 30 * Register commands. 31 */ 32 public static function init() { 33 WP_CLI::add_command( 34 'weareplanet settings init', 35 array( 36 __CLASS__, 37 'settings_init', 38 ) 39 ); 40 WP_CLI::add_command( 41 'weareplanet webhooks install', 42 array( 43 __CLASS__, 44 'webhooks_install', 45 ) 46 ); 47 WP_CLI::add_command( 48 'weareplanet payment-methods sync', 49 array( 50 __CLASS__, 51 'payment_methods_sync', 52 ) 53 ); 54 } 55 55 56 /**57 * Initialize WeArePlanet settings.58 * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet.59 *60 * ## EXAMPLE61 *62 *$ wp weareplanet settings init63 *64 * @param array $args WP-CLI positional arguments.65 * @param array $assoc_args WP-CLI associative arguments.66 */67 public static function settings_init( $args, $assoc_args ) {68 try {69 $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings();70 foreach ( $default_settings as $setting => $value ) {71 $current_setting = get_option( $setting, false );72 if ( $current_setting === false) {73 update_option( $setting, $value );74 }75 }76 WP_CLI::success( "Settings initialized.");77 } catch ( \Exception $e ) {78 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );79 WP_CLI::error( "Failed to initialize settings: ". $e->getMessage() );80 }81 }56 /** 57 * Initialize WeArePlanet settings. 58 * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet. 59 * 60 * ## EXAMPLE 61 * 62 * $ wp weareplanet settings init 63 * 64 * @param array $args WP-CLI positional arguments. 65 * @param array $assoc_args WP-CLI associative arguments. 66 */ 67 public static function settings_init( $args, $assoc_args ) { 68 try { 69 $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings(); 70 foreach ( $default_settings as $setting => $value ) { 71 $current_setting = get_option( $setting, false ); 72 if ( false === $current_setting ) { 73 update_option( $setting, $value ); 74 } 75 } 76 WP_CLI::success( 'Settings initialized.' ); 77 } catch ( \Exception $e ) { 78 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR ); 79 WP_CLI::error( 'Failed to initialize settings: ' . $e->getMessage() ); 80 } 81 } 82 82 83 /**84 * Create webhook URL and webhook listeners in the portal for WeArePlanet.85 *86 * ## EXAMPLE87 *88 *$ wp weareplanet webhooks install89 *90 * @param array $args WP-CLI positional arguments.91 * @param array $assoc_args WP-CLI associative arguments.92 */93 public static function webhooks_install( $args, $assoc_args ) {94 try {95 WC_WeArePlanet_Helper::instance()->reset_api_client();96 WC_WeArePlanet_Service_Webhook::instance()->install();97 WP_CLI::success( "Webhooks installed.");98 } catch ( \Exception $e ) {99 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );100 WP_CLI::error( "Failed to install webhooks: ". $e->getMessage() );101 }102 }83 /** 84 * Create webhook URL and webhook listeners in the portal for WeArePlanet. 85 * 86 * ## EXAMPLE 87 * 88 * $ wp weareplanet webhooks install 89 * 90 * @param array $args WP-CLI positional arguments. 91 * @param array $assoc_args WP-CLI associative arguments. 92 */ 93 public static function webhooks_install( $args, $assoc_args ) { 94 try { 95 WC_WeArePlanet_Helper::instance()->reset_api_client(); 96 WC_WeArePlanet_Service_Webhook::instance()->install(); 97 WP_CLI::success( 'Webhooks installed.' ); 98 } catch ( \Exception $e ) { 99 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR ); 100 WP_CLI::error( 'Failed to install webhooks: ' . $e->getMessage() ); 101 } 102 } 103 103 104 /**105 * Synchronizes payment methods in the WeArePlanet from the portal.106 *107 * ## EXAMPLE108 *109 *$ wp weareplanet payment-methods sync110 *111 * @param array $args WP-CLI positional arguments.112 * @param array $assoc_args WP-CLI associative arguments.113 */114 public static function payment_methods_sync( $args, $assoc_args ) {115 try {116 WC_WeArePlanet_Helper::instance()->reset_api_client();117 WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize();118 WC_WeArePlanet_Helper::instance()->delete_provider_transients();119 WP_CLI::success( "Payment methods synchronized.");120 } catch ( \Exception $e ) {121 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );122 WP_CLI::error( "Failed to synchronize payment methods: ". $e->getMessage() );123 }124 }125 }104 /** 105 * Synchronizes payment methods in the WeArePlanet from the portal. 106 * 107 * ## EXAMPLE 108 * 109 * $ wp weareplanet payment-methods sync 110 * 111 * @param array $args WP-CLI positional arguments. 112 * @param array $assoc_args WP-CLI associative arguments. 113 */ 114 public static function payment_methods_sync( $args, $assoc_args ) { 115 try { 116 WC_WeArePlanet_Helper::instance()->reset_api_client(); 117 WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize(); 118 WC_WeArePlanet_Helper::instance()->delete_provider_transients(); 119 WP_CLI::success( 'Payment methods synchronized.' ); 120 } catch ( \Exception $e ) { 121 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR ); 122 WP_CLI::error( 'Failed to synchronize payment methods: ' . $e->getMessage() ); 123 } 124 } 125 } 126 126 } 127 127 -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-customer-document.php
r3288388 r3740659 109 109 array( 110 110 'weareplanet_action' => 'download_packing', 111 'post' => $order_id,112 'nonce' => wp_create_nonce( 'download_packing' ),111 'post' => $order_id, 112 'nonce' => wp_create_nonce( 'download_packing' ), 113 113 ) 114 114 ) … … 130 130 */ 131 131 private static function is_pdf_request() { 132 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- nonce is verified in download_document() 132 133 return ( isset( $_GET['post'] ) && isset( $_GET['weareplanet_action'] ) && isset( $_GET['nonce'] ) ); 134 // phpcs:enable WordPress.Security.NonceVerification.Recommended 133 135 } 134 136 -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-email.php
r3378673 r3740659 28 28 /** 29 29 * Allow on hold emails being sent when germanized plugin is installed. 30 * 31 * @var bool 30 32 */ 31 33 private static $allow_on_hold_emails = false; … … 39 41 array( 40 42 __CLASS__, 41 'send_on_hold_email_when_authorized'43 'send_on_hold_email_when_authorized', 42 44 ), 43 45 10, … … 156 158 add_filter( 'woocommerce_email_actions', array( __CLASS__, 'add_email_actions' ), 10, 1 ); 157 159 add_filter( 'woocommerce_email_classes', array( __CLASS__, 'add_email_classes' ), 100, 1 ); 158 add_filter( 159 'woocommerce_email_enabled_customer_on_hold_order', 160 array( __CLASS__, 'disable_pending_payment_email' ), 161 10, 162 2 163 ); 164 } 165 166 /** 167 * @param $order_id 160 add_filter( 161 'woocommerce_email_enabled_customer_on_hold_order', 162 array( __CLASS__, 'disable_pending_payment_email' ), 163 10, 164 2 165 ); 166 } 167 168 /** 169 * Trigger the on-hold email when an order is authorized. 170 * 171 * @param int $order_id order id. 168 172 * @return void 169 173 */ … … 336 340 public static function add_email_actions( $actions ) { 337 341 338 $to_add = array(339 'woocommerce_order_status_wearep-redirected_to_processing',340 'woocommerce_order_status_wearep-redirected_to_completed',341 'woocommerce_order_status_wearep-redirected_to_on-hold',342 'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting',343 'woocommerce_order_status_wearep-redirected_to_weareplanet-manual',344 'woocommerce_order_status_wearep-manual_to_cancelled',345 'woocommerce_order_status_wearep-waiting_to_cancelled',346 'woocommerce_order_status_wearep-manual_to_processing',347 'woocommerce_order_status_wearep-waiting_to_processing',348 );349 350 $authorized_status = self::get_transaction_mapped_status( 'authorized' );351 $fulfill_status = self::get_transaction_mapped_status( 'fulfill' );352 353 if ( $authorized_status && $fulfill_status ) {354 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status );355 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status );356 }342 $to_add = array( 343 'woocommerce_order_status_wearep-redirected_to_processing', 344 'woocommerce_order_status_wearep-redirected_to_completed', 345 'woocommerce_order_status_wearep-redirected_to_on-hold', 346 'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting', 347 'woocommerce_order_status_wearep-redirected_to_weareplanet-manual', 348 'woocommerce_order_status_wearep-manual_to_cancelled', 349 'woocommerce_order_status_wearep-waiting_to_cancelled', 350 'woocommerce_order_status_wearep-manual_to_processing', 351 'woocommerce_order_status_wearep-waiting_to_processing', 352 ); 353 354 $authorized_status = self::get_transaction_mapped_status( 'authorized' ); 355 $fulfill_status = self::get_transaction_mapped_status( 'fulfill' ); 356 357 if ( $authorized_status && $fulfill_status ) { 358 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status ); 359 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status ); 360 } 357 361 358 362 if ( class_exists( 'woocommerce_wpml' ) ) { … … 537 541 break; 538 542 539 case 'WC_Email_Customer_On_Hold_Order':540 add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 );541 if ( $authorized_status && $fulfill_status ) {542 add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 );543 }544 break;545 546 case 'WC_Email_Customer_Processing_Order':547 add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );548 add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );549 add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );550 if ( $authorized_status && $fulfill_status ) {551 add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 );552 }553 break;543 case 'WC_Email_Customer_On_Hold_Order': 544 add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 ); 545 if ( $authorized_status && $fulfill_status ) { 546 add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 ); 547 } 548 break; 549 550 case 'WC_Email_Customer_Processing_Order': 551 add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 ); 552 add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 ); 553 add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 ); 554 if ( $authorized_status && $fulfill_status ) { 555 add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 ); 556 } 557 break; 554 558 555 559 case 'WC_Email_Customer_Completed_Order': … … 575 579 * @return bool 576 580 */ 577 public static function gzd_block_send_instant_order_confirmation ( $email_sent, $order ) {581 public static function gzd_block_send_instant_order_confirmation( $email_sent, $order ) { 578 582 if ( ! ( $order instanceof WC_Order ) ) { 579 583 return $email_sent; … … 623 627 624 628 /** 625 * @param WC_Order $order 629 * Check if the order is an on-hold order and if it is authorized. 630 * 631 * @param WC_Order $order WooCommerce order object. 626 632 * @return bool 627 633 */ … … 639 645 } 640 646 641 /**642 * This prevents WooCommerce from sending the "customer on hold" email643 * when the order was placed using any WeArePlanet payment method644 * and the merchant has disabled this behavior in the plugin settings.645 *646 * @param bool $enabled Whether the email is enabled.647 * @param WC_Order $orderWooCommerce order object.648 *649 * @return bool650 */651 public static function disable_pending_payment_email( $enabled, $order ) {652 if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) {653 return $enabled;654 }655 656 $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' );657 $gateway = wc_get_payment_gateway_by_order( $order );658 659 if ( $gateway instanceof WC_WeArePlanet_Gateway && $disable === 'yes') {660 return false;661 }662 663 return $enabled;664 }647 /** 648 * This prevents WooCommerce from sending the "customer on hold" email 649 * when the order was placed using any WeArePlanet payment method 650 * and the merchant has disabled this behavior in the plugin settings. 651 * 652 * @param bool $enabled Whether the email is enabled. 653 * @param WC_Order $order WooCommerce order object. 654 * 655 * @return bool 656 */ 657 public static function disable_pending_payment_email( $enabled, $order ) { 658 if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) { 659 return $enabled; 660 } 661 662 $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' ); 663 $gateway = wc_get_payment_gateway_by_order( $order ); 664 665 if ( $gateway instanceof WC_WeArePlanet_Gateway && 'yes' === $disable ) { 666 return false; 667 } 668 669 return $enabled; 670 } 665 671 } 666 672 -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-gateway.php
r3550708 r3740659 278 278 $field_key = $this->get_field_key( $key ); 279 279 $defaults = array( 280 'title' => '',281 'class' => '',282 'css' => '',283 'placeholder' => '',284 'desc_tip' => true,285 'description' => '',280 'title' => '', 281 'class' => '', 282 'css' => '', 283 'placeholder' => '', 284 'desc_tip' => true, 285 'description' => '', 286 286 'custom_attributes' => array(), 287 287 ); … … 292 292 <th scope="row" class="titledesc"> 293 293 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $data['title'] ); ?></label> 294 <?php echo $this->get_tooltip_html( $data); ?>294 <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?> 295 295 </th> 296 296 <td class="forminp"> … … 303 303 id="<?php echo esc_attr( $field_key ); ?>" 304 304 style="<?php echo esc_attr( $data['css'] ); ?>" 305 <?php echo $this->get_custom_attribute_html( $data); ?>305 <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> 306 306 > 307 307 <?php echo wp_kses_post( $data['value'] ); ?> … … 331 331 static $checking = false; 332 332 if ( $checking ) { 333 return false; // prevent reentry/loop 333 return false; // prevent reentry/loop. 334 334 } 335 335 $checking = true; 336 336 337 337 try { 338 // Respect parent availability 338 // Respect parent availability. 339 339 if ( ! parent::is_available() ) { 340 340 return false; 341 341 } 342 342 343 // Prevent conflict with tax rounding 343 // Prevent conflict with tax rounding. 344 344 if ( wc_tax_enabled() && 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) { 345 345 if ( 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY ) ) { … … 350 350 } 351 351 352 // Use session cache if available 352 // Use session cache if available. 353 353 $gateway_available = WC()->session && $this->has_session() 354 354 ? WC()->session->get( 'weareplanet_payment_gateways' ) … … 359 359 } 360 360 361 // Allow admin and non-checkout pages to pass 361 // Allow admin and non-checkout pages to pass. 362 362 if ( apply_filters( 363 363 'weareplanet_is_method_available', … … 368 368 } 369 369 370 // Handle "order received" page logic 370 // Handle "order received" page logic. 371 371 global $wp; 372 372 if ( is_checkout() && isset( $wp->query_vars['order-received'] ) ) { … … 374 374 } 375 375 376 // Handle "order pay" endpoint 376 // Handle "order pay" endpoint. 377 377 if ( apply_filters( 'wc_weareplanet_is_order_pay_endpoint', is_checkout_pay_page() ) ) { 378 378 $order = WC_Order_Factory::get_order( $wp->query_vars['order-pay'] ?? 0 ); … … 385 385 } 386 386 387 // Check if this gateway is among the possible ones 387 // Check if this gateway is among the possible ones. 388 388 $possible = false; 389 389 foreach ( $possible_methods as $method_id ) { … … 398 398 } 399 399 400 // Cache success in session 400 // Cache success in session. 401 401 if ( WC()->session && $this->has_session() ) { 402 402 $gateway_available[ $this->pln_payment_method_configuration_id ] = true; … … 538 538 } 539 539 540 /** 541 * Enqueue checkout scripts. 542 */ 540 543 public function enqueue_checkout_scripts() { 541 544 if ( ! is_checkout() && ! is_checkout_pay_page() ) { … … 565 568 } 566 569 567 if (get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE) {568 return false;570 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE ) { 571 return false; 569 572 } 570 573 571 574 wp_enqueue_script( 572 'weareplanet-remote-checkout-js',573 $ajax_url,574 array(575 'jquery',576 ),577 1,578 true575 'weareplanet-remote-checkout-js', 576 $ajax_url, 577 array( 578 'jquery', 579 ), 580 1, 581 true 579 582 ); 580 583 wp_enqueue_script( 581 'weareplanet-checkout-js',582 WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js',583 array(584 'jquery',585 'jquery-blockui',586 'weareplanet-remote-checkout-js',587 ),588 1,589 true584 'weareplanet-checkout-js', 585 WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js', 586 array( 587 'jquery', 588 'jquery-blockui', 589 'weareplanet-remote-checkout-js', 590 ), 591 1, 592 true 590 593 ); 591 594 global $wp_version; 592 595 $localize = array( 593 'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ),594 'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ),595 'versions' => array(596 'wordpress' => $wp_version,597 'woocommerce' => $woocommerce_data['Version'],598 'weareplanet' => WC_WEAREPLANET_VERSION,599 ),596 'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ), 597 'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ), 598 'versions' => array( 599 'wordpress' => $wp_version, 600 'woocommerce' => $woocommerce_data['Version'], 601 'weareplanet' => WC_WEAREPLANET_VERSION, 602 ), 600 603 ); 601 604 wp_localize_script( 'weareplanet-checkout-js', 'weareplanet_js_params', $localize ); … … 666 669 667 670 [ $result, $transaction ] = $this->process_payment_transaction( $order, $transaction_id, $space_id, $is_order_pay_endpoint, $transaction_service ); 668 669 671 670 672 $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ); … … 717 719 * in the order. It also sets up the redirect URL upon successful payment and returns the result and transaction. 718 720 * 719 * @param WC_Order $order The WooCommerce order object.720 * @param int $transaction_id The ID of the transaction.721 * @param int $space_id The space ID associated with the transaction.722 * @param bool $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint.721 * @param WC_Order $order The WooCommerce order object. 722 * @param int $transaction_id The ID of the transaction. 723 * @param int $space_id The space ID associated with the transaction. 724 * @param bool $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint. 723 725 * @param WC_WeArePlanet_Service_Transaction $transaction_service The transaction service instance. 724 726 * @return array An array containing the result of the transaction and the transaction object. -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-helper.php
r3676036 r3740659 76 76 * 77 77 * @param string $status_slug Order status slug, with or without the `wc-` prefix. 78 * @param bool $prefixed When true the returned status contains the `wc-` prefix.78 * @param bool $prefixed When true the returned status contains the `wc-` prefix. 79 79 * @return string 80 80 */ … … 121 121 122 122 /** 123 * Delete language transient. 124 * 125 * @return void 126 */ 127 public function delete_language_transient() { 128 delete_transient( 'wc_weareplanet_languages' ); 129 } 130 131 /** 123 132 * Get api client. 124 133 * … … 144 153 * Add headers to api client. 145 154 * 155 * @param \WeArePlanet\Sdk\ApiClient $api_client api client. 146 156 * @param array $additional_headers Additional headers. 147 157 * @return void 148 158 */ 149 public static function add_headers( &$api_client, array $additional_headers = []) {159 public static function add_headers( &$api_client, array $additional_headers = array() ) { 150 160 $default_header_data = self::get_default_header_data(); 151 161 $default_header_data = array_merge( $default_header_data, $additional_headers ); … … 269 279 $name = $line_item->getName(); 270 280 271 // Handle coupons normally 281 // Handle coupons normally. 272 282 if ( $exclude_discounts && \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type 273 283 && strpos( $name, WC_WeArePlanet_Packages_Coupon_Discount::WEAREPLANET_COUPON ) !== false … … 275 285 // Convert negative values to positive in order to be able to subtract it. 276 286 $sum -= abs( $line_item->getAmountIncludingTax() ); 277 } 278 // Handle gift cards separately (already negative, do not abs()) 279 elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type 280 && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD) !== false 287 } elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type 288 && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD ) !== false 281 289 ) { 290 // Handle gift cards separately (already negative, do not abs()). 282 291 $sum += $line_item->getAmountIncludingTax(); 283 } 284 else { 292 } else { 285 293 $sum += $line_item->getAmountIncludingTax(); 286 294 } … … 295 303 * @param mixed $expected_sum expected sum. 296 304 * @param mixed $currency currency. 305 * @param bool $is_recurrent is recurrent. 297 306 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] 298 307 * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount. … … 301 310 // Check if coupon is applied to order. Session cart might be empty during webhook processing. 302 311 $has_coupons = apply_filters( 'wc_weareplanet_packages_coupon_line_items_have_coupon_discounts', $line_items, $currency ); 303 // ensure that the effective sum coincides with the total discounted by the coupons.312 // ensure that the effective sum coincides with the total discounted by the coupons. 304 313 $effective_sum = $this->round_amount( $this->get_total_amount_including_tax( $line_items, $has_coupons ), $currency ); 305 314 $rounded_expected_sum = $this->round_amount( $expected_sum, $currency ); … … 441 450 $locked_at = gmdate( 'Y-m-d H:i:s' ); 442 451 $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info'; 443 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.452 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 444 453 $wpdb->query( 445 454 $wpdb->prepare( … … 450 459 ); 451 460 452 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .453 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.461 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 462 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 454 463 $wpdb->query( 455 464 $wpdb->prepare( … … 462 471 ) 463 472 ); 464 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .473 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 465 474 } 466 475 … … 634 643 635 644 $shop_version = str_replace( 'v', '', $version ); 636 $plugin_version = '3.4. 8';645 $plugin_version = '3.4.9'; 637 646 list ($major_version, $minor_version) = explode( '.', $shop_version, 3 ); 638 647 return array( … … 645 654 646 655 /** 647 * Get WooCommerce order statuses in JSON format.648 *649 * This method retrieves the WooCommerce order statuses, applies any filters,650 * and returns them as an array with structured data.651 *652 * @return array[] An array of WooCommerce order statuses, where each status is represented653 * as an associative array containing:654 * - 'key' (string) : The order status key.655 * - 'label' (string) : The human-readable label for the status.656 * - 'type' (string) : The type of status ('core' if it starts with 'wc-', otherwise 'custom').657 */656 * Get WooCommerce order statuses in JSON format. 657 * 658 * This method retrieves the WooCommerce order statuses, applies any filters, 659 * and returns them as an array with structured data. 660 * 661 * @return array[] An array of WooCommerce order statuses, where each status is represented 662 * as an associative array containing: 663 * - 'key' (string) : The order status key. 664 * - 'label' (string) : The human-readable label for the status. 665 * - 'type' (string) : The type of status ('core' if it starts with 'wc-', otherwise 'custom'). 666 */ 658 667 public function get_woocommerce_order_statuses_json() { 659 668 $woocommerce_statuses = apply_filters( 'weareplanet_woocommerce_statuses', array() ); … … 667 676 'wc-failed', 668 677 'wc-trash', 669 'wc-checkout-draft' 678 'wc-checkout-draft', 670 679 ); 671 680 if ( self::is_custom_status_mapping_enabled() ) { … … 675 684 'wc-wearep-manual', 676 685 'wc-wearep-redirected', 677 'wc-wearep-waiting' 686 'wc-wearep-waiting', 678 687 ) 679 688 ); 680 689 } 681 690 682 return array_map( function( $key, $value ) use ( $excluded_statuses ) { 691 return array_map( 692 function ( $key, $value ) use ( $excluded_statuses ) { 683 693 return array( 684 694 'key' => $key, … … 693 703 694 704 /** 695 * @param $order 705 * Set virtual zero total orders to complete. 706 * 707 * @param WC_Order $order WC_Order The WooCommerce order object. 696 708 * @return void 697 709 */ … … 704 716 705 717 /** 706 * @param $order 718 * Check if the order is virtual (contains only virtual products). 719 * 720 * @param WC_Order $order WC_Order The WooCommerce order object. 707 721 * @return bool 708 722 */ … … 728 742 * Update WooCommerce order status to "Pre-Order" if any product is out of stock or marked as pre-order. 729 743 * 730 * @param WC_Order $order WooCommerce order object.744 * @param WC_Order $order WooCommerce order object. 731 745 */ 732 746 public static function update_order_status_for_preorder_if_needed( $order ) { … … 757 771 758 772 if ( $is_preorder_wc || $is_preorder_yith ) { 759 // Check if order is marked as pre-ordered 773 // Check if order is marked as pre-ordered. 760 774 if ( 'yes' !== $order->get_meta( '_order_has_preorder' ) ) { 761 775 return; 762 776 } 763 777 764 // Check if Yith Pre-Order plugin setting 778 // Check if Yith Pre-Order plugin setting. 765 779 if ( 'default' === get_option( 'ywpo_order_status', 'default' ) ) { 766 780 return; … … 770 784 } 771 785 772 // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available 786 // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available. 773 787 if ( ( $product->get_stock_quantity() ?? 1 ) < 1 ) { 774 788 $is_out_of_stock = true; … … 777 791 } 778 792 779 if ( ! $is_preorder && !$is_out_of_stock ) {793 if ( ! $is_preorder && ! $is_out_of_stock ) { 780 794 return; 781 795 } … … 796 810 797 811 $order->update_status( 798 $preorder_status_slug,799 __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' )812 $preorder_status_slug, 813 __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' ) 800 814 ); 801 815 802 816 $order->add_order_note( 803 __( 'Order status automatically set to pre-order.', 'woo-weareplanet' )817 __( 'Order status automatically set to pre-order.', 'woo-weareplanet' ) 804 818 ); 805 819 } … … 823 837 return $settings; 824 838 } 825 826 839 } -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-migration.php
r3676036 r3740659 56 56 '1.0.9' => 'update_1_0_9_restore_default_status_mappings', 57 57 '1.0.10' => 'update_1_0_10_remove_previous_min_version', 58 '1.0.11' => 'update_1_0_11_enforce_signed_webhook_listeners', 59 '1.0.12' => 'update_1_0_12_clear_language_cache', 58 60 ); 59 61 … … 74 76 array( 75 77 __CLASS__, 76 'wp_initialize_site' 78 'wp_initialize_site', 77 79 ), 78 80 10, … … 180 182 * Create tables if new MU blog is created 181 183 * 182 * wp_initialize_site hook introduced since 5.1.0 184 * Function wp_initialize_site hook introduced since 5.1.0 185 * 183 186 * @link https://developer.wordpress.org/reference/hooks/wp_initialize_site/ 184 187 * 185 * @param WP_Site $site 186 * @param array $args188 * @param WP_Site $site site. 189 * @param array $args arguments. 187 190 * @return void 188 191 */ … … 190 193 if ( is_plugin_active_for_network( 'woo-weareplanet/weareplanet.php' ) ) { 191 194 $blog_id = $site->blog_id; 192 // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error 195 // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error. 193 196 if ( ! $blog_id ) { 194 197 $logger = wc_get_logger(); 195 $logger->error( 'Could not detect blog_id during wp_initialize_site.', [ 'source' => 'weareplanet' ]);198 $logger->error( 'Could not detect blog_id during wp_initialize_site.', array( 'source' => 'weareplanet' ) ); 196 199 return; 197 200 } … … 252 255 $current_version = get_option( self::WEAREPLANET_CK_DB_VERSION, 0 ); 253 256 $version_keys = array_keys( self::$db_migrations ); 254 if ( $current_version === 0 || version_compare( $current_version, '0', '>' ) && version_compare( $current_version, end( $version_keys ), '<' ) ) { 257 if ( version_compare( $current_version, end( $version_keys ), '<' ) 258 && ( 259 0 === $current_version 260 || version_compare( $current_version, '0', '>' ) 261 ) 262 ) { 255 263 // We migrate the Db for all blogs. 256 264 self::install_db( true ); … … 279 287 if ( WC_WEAREPLANET_PLUGIN_BASENAME === $file ) { 280 288 $row_meta = array( 281 'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4. 8/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>',289 'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>', 282 290 ); 283 291 … … 297 305 298 306 $table_method_config = $wpdb->prefix . 'weareplanet_method_config'; 299 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.307 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 300 308 $sql = "CREATE TABLE IF NOT EXISTS $table_method_config( 301 309 `id` int(10) unsigned NOT NULL AUTO_INCREMENT, … … 315 323 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; 316 324 // phpcs:enable 317 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery -- $sql is prepared.325 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $sql is prepared. 318 326 $result = $wpdb->query( $sql ); 319 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery 327 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter 320 328 321 329 if ( false === $result ) { … … 325 333 $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info'; 326 334 327 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.335 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 328 336 $result = $wpdb->query( 329 337 "CREATE TABLE IF NOT EXISTS $table_transaction_info( … … 350 358 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 351 359 ); 352 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .360 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter 353 361 354 362 if ( false === $result ) { … … 358 366 $table_token_info = $wpdb->prefix . 'weareplanet_token_info'; 359 367 360 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.368 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 361 369 $result = $wpdb->query( 362 370 "CREATE TABLE IF NOT EXISTS $table_token_info( … … 378 386 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 379 387 ); 380 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .388 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 381 389 382 390 if ( false === $result ) { … … 386 394 $table_completion_job = $wpdb->prefix . 'weareplanet_completion_job'; 387 395 388 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.396 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 389 397 $result = $wpdb->query( 390 398 "CREATE TABLE IF NOT EXISTS $table_completion_job( … … 406 414 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 407 415 ); 408 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .416 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 409 417 410 418 if ( false === $result ) { … … 414 422 $table_void_job = $wpdb->prefix . 'weareplanet_void_job'; 415 423 416 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.424 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 417 425 $result = $wpdb->query( 418 426 "CREATE TABLE IF NOT EXISTS $table_void_job( … … 432 440 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 433 441 ); 434 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .442 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 435 443 436 444 if ( false === $result ) { … … 440 448 $table_refund_job = $wpdb->prefix . 'weareplanet_refund_job'; 441 449 442 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.450 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 443 451 $result = $wpdb->query( 444 452 "CREATE TABLE IF NOT EXISTS $table_refund_job( … … 459 467 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 460 468 ); 461 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .469 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 462 470 463 471 if ( false === $result ) { … … 477 485 $table_method_config = $wpdb->prefix . 'weareplanet_method_config'; 478 486 479 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.487 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 480 488 $result = $wpdb->query( "ALTER TABLE $table_method_config CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" ); 481 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .482 483 if ( false === $result ) { 484 throw new Exception( esc_html( $wpdb->last_error ) ); 485 } 486 487 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.489 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 490 491 if ( false === $result ) { 492 throw new Exception( esc_html( $wpdb->last_error ) ); 493 } 494 495 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 488 496 $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" ); 489 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .497 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 490 498 491 499 if ( false === $result ) { … … 505 513 $table_token_info = $wpdb->prefix . 'weareplanet_token_info'; 506 514 507 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.515 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 508 516 $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `order_id` `order_id` int(10) unsigned NULL DEFAULT NULL" ); 509 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .510 511 if ( false === $result ) { 512 throw new Exception( esc_html( $wpdb->last_error ) ); 513 } 514 515 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.517 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 518 519 if ( false === $result ) { 520 throw new Exception( esc_html( $wpdb->last_error ) ); 521 } 522 523 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 516 524 $result = $wpdb->query( 517 525 $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'order_mapping_id' ) 518 526 ); 519 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .527 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 520 528 521 529 if ( 0 === $result ) { 522 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.530 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 523 531 $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD `order_mapping_id` int(10) unsigned NULL AFTER order_id" ); 524 532 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery … … 529 537 } 530 538 531 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.539 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 532 540 $result = $wpdb->query( "ALTER TABLE $table_token_info CHANGE `customer_id` `customer_id` int(10) unsigned NULL DEFAULT NULL" ); 533 541 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery … … 552 560 553 561 if ( 0 === $result ) { 554 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.562 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 555 563 $result = $wpdb->query( "ALTER TABLE $table_method_config ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" ); 556 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .564 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 557 565 558 566 if ( false === $result ) { … … 561 569 } 562 570 563 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.571 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 564 572 $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'image_base' ) ); 565 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .573 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 566 574 567 575 if ( 0 === $result ) { 568 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.576 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 569 577 $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" ); 570 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .578 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 571 579 572 580 if ( false === $result ) { … … 587 595 $table_attribute_options = $wpdb->prefix . 'weareplanet_attribute_options'; //phpcs:ignore 588 596 589 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.597 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 590 598 $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'user_failure_message' ) ); 591 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .599 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 592 600 593 601 if ( 0 === $result ) { 594 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.602 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 595 603 $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `user_failure_message` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER failure_reason" ); 596 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .604 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 597 605 598 606 if ( false === $result ) { … … 601 609 } 602 610 // Do not use foreign keys to reference attribute to cascade deletion, as some shop still run with MyISAM enginge as default. 603 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.611 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 604 612 $result = $wpdb->query( 605 613 "CREATE TABLE IF NOT EXISTS $table_attribute_options( … … 611 619 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 612 620 ); 613 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .621 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 614 622 615 623 if ( false == $result ) { … … 703 711 global $wpdb; 704 712 // rollback table rename if there are issues. 705 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.713 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 706 714 $wpdb->query( 'START TRANSACTION' ); //phpcs:ignore 707 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .715 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 708 716 $table_stament = 'Tables_in_' . $wpdb->dbname; 709 717 710 718 foreach ( $table_rename_map as $old_table_name => $new_table_name ) { 711 719 // check old table exists. 712 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.720 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 713 721 $old_table_result = $wpdb->get_row( 714 722 $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $old_table_name ) 715 723 ); 716 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .724 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 717 725 718 726 if ( $old_table_result ) { 719 727 // check new table doesn't exist, if it does there's a problem!. 720 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.728 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 721 729 $new_table_result = $wpdb->get_row( 722 730 $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $new_table_name ) 723 731 ); 724 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .732 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 725 733 726 734 if ( ! $new_table_result ) { 727 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.735 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 728 736 $result = $wpdb->query( "RENAME TABLE $old_table_name TO $new_table_name" ); 729 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .737 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 730 738 if ( false === $result ) { 731 739 throw new Exception( esc_html( $wpdb->last_error ) ); … … 762 770 */ 763 771 public static function update_1_0_10_remove_previous_min_version() { 764 delete_metadata( 'user', 0, "weareplanet-previous-wc-min-version", '', true ); 772 delete_metadata( 'user', 0, 'weareplanet-previous-wc-min-version', '', true ); 773 } 774 775 /** 776 * Enforces payload signatures on webhook listeners. 777 */ 778 public static function update_1_0_11_enforce_signed_webhook_listeners() { 779 WC_WeArePlanet_Service_Webhook::instance()->enforce_signed_listeners(); 780 } 781 782 /** 783 * Clear the language cache, which earlier versions filled with languages without IETF codes. 784 * Only the cache is removed, it is rebuilt on the next access. 785 */ 786 public static function update_1_0_12_clear_language_cache() { 787 WC_WeArePlanet_Helper::instance()->delete_language_transient(); 765 788 } 766 789 } -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-order-reference.php
r3288388 r3740659 1 1 <?php 2 3 2 /** 4 3 * Plugin Name: WeArePlanet -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-order-status-adapter.php
r3463230 r3740659 23 23 * based on the transaction statuses in WeArePlanet. 24 24 */ 25 class WC_WeArePlanet_Order_Status_Adapter 26 { 25 class WC_WeArePlanet_Order_Status_Adapter { 27 26 /** 28 27 * Constants for WeArePlanet transaction statuses. 29 28 */ 30 const WEAREPLANET_STATUS_PENDING = 'pending';31 const WEAREPLANET_STATUS_CONFIRMED = 'confirmed';29 const WEAREPLANET_STATUS_PENDING = 'pending'; 30 const WEAREPLANET_STATUS_CONFIRMED = 'confirmed'; 32 31 const WEAREPLANET_STATUS_PROCESSING = 'processing'; 33 32 const WEAREPLANET_STATUS_AUTHORIZED = 'authorized'; 34 const WEAREPLANET_STATUS_COMPLETED = 'completed';35 const WEAREPLANET_STATUS_FAILED = 'failed';36 const WEAREPLANET_STATUS_VOIDED = 'voided';37 const WEAREPLANET_STATUS_FULFILL = 'fulfill';38 const WEAREPLANET_STATUS_DECLINE = 'decline';33 const WEAREPLANET_STATUS_COMPLETED = 'completed'; 34 const WEAREPLANET_STATUS_FAILED = 'failed'; 35 const WEAREPLANET_STATUS_VOIDED = 'voided'; 36 const WEAREPLANET_STATUS_FULFILL = 'fulfill'; 37 const WEAREPLANET_STATUS_DECLINE = 'decline'; 39 38 40 39 const WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX = 'weareplanet_order_status_mapping_'; 41 const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX = 'weareplanet_custom_order_status_';40 const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX = 'weareplanet_custom_order_status_'; 42 41 /** 43 42 * Stores the status mappings loaded from the database. … … 52 51 * Initializes the settings and adds the filter for updating order status. 53 52 */ 54 public function __construct() 55 { 53 public function __construct() { 56 54 $this->initialize_filters(); 57 55 $this->initialize_status_mappings(); … … 61 59 * Initialise filters and actions. 62 60 */ 63 public static function init(): void 64 { 61 public static function init(): void { 65 62 add_action( 'plugins_loaded', array( __CLASS__, 'register_weareplanet_service_status_adapter' ) ); 66 63 } … … 74 71 * @return void 75 72 */ 76 public static function register_weareplanet_service_status_adapter(): void 77 { 73 public static function register_weareplanet_service_status_adapter(): void { 78 74 new WC_WeArePlanet_Order_Status_Adapter(); 79 75 } … … 82 78 * Initialize filters. 83 79 */ 84 private function initialize_filters(): void 85 { 80 private function initialize_filters(): void { 86 81 add_filter( 'weareplanet_default_order_status_mappings', array( $this, 'get_default_status_mappings' ) ); 87 82 add_filter( 'weareplanet_woocommerce_statuses', array( $this, 'get_all_woocommerce_statuses' ) ); … … 93 88 add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'get_order_status_on_payment_complete' ), 10, 3 ); 94 89 95 // tests.90 // tests. 96 91 // CPT-based orders. 97 add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_shop_order'), 20, 1 );98 add_action( 'handle_bulk_actions-edit-shop_order', array( $this, 'bulk_process_custom_status'), 20, 3 );92 add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_shop_order' ), 20, 1 ); 93 add_action( 'handle_bulk_actions-edit-shop_order', array( $this, 'bulk_process_custom_status' ), 20, 3 ); 99 94 // HPOS orders. 100 add_filter( 'bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_actions_shop_order'), 20, 1 );101 add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_process_custom_status'), 20, 3 );95 add_filter( 'bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_actions_shop_order' ), 20, 1 ); 96 add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_process_custom_status' ), 20, 3 ); 102 97 } 103 98 … … 133 128 global $wpdb; 134 129 135 $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE. 136 $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A ); 137 138 //Build the array with the desired structure. 130 $cache_key = 'weareplanet_custom_order_statuses'; 131 $cache_group = 'weareplanet'; 132 133 $results = wp_cache_get( $cache_key, $cache_group ); 134 135 if ( $results === false ) { 136 $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE. 137 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 138 $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A ); 139 140 wp_cache_set( $cache_key, $results, $cache_group, HOUR_IN_SECONDS ); 141 } 142 143 // Build the array with the desired structure. 139 144 foreach ( $results as $row ) { 140 145 $status_label = ucfirst( str_replace( array( 'wc-', '_' ), array( '', ' ' ), $row['option_value'] ) ); 146 141 147 $order_statuses[ $row['option_value'] ] = $status_label; 142 148 } … … 161 167 ); 162 168 163 $order_statuses_without_prefix = array_map( function( $status ) { 164 return str_replace( 'wc-', '', $status ); 165 }, array_values( $default_mappings ) ); 166 167 return array_merge($order_statuses, $order_statuses_without_prefix); 169 $order_statuses_without_prefix = array_map( 170 function ( $status ) { 171 return str_replace( 'wc-', '', $status ); 172 }, 173 array_values( $default_mappings ) 174 ); 175 176 return array_merge( $order_statuses, $order_statuses_without_prefix ); 168 177 } 169 178 … … 171 180 * Loads the status mappings from the database or initializes them if not present. 172 181 */ 173 private function initialize_status_mappings(): void 174 { 182 private function initialize_status_mappings(): void { 175 183 $is_custom_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled(); 176 184 $default_mappings = apply_filters( 'weareplanet_default_order_status_mappings', array() ); … … 203 211 * @return bool 204 212 */ 205 private function is_custom_order_status( string $order_status ): bool 206 { 213 private function is_custom_order_status( string $order_status ): bool { 207 214 return strpos( $order_status, 'wc-wearep-' ) === 0 || strpos( $order_status, 'wearep-' ) === 0; 208 215 } … … 214 221 * @return string 215 222 */ 216 private function ensure_status_has_prefix( string $status ): string 217 { 223 private function ensure_status_has_prefix( string $status ): string { 218 224 if ( '' === $status ) { 219 225 return $status; … … 236 242 * @return void 237 243 */ 238 public function store_default_status_mappings_on_database(): void 239 { 244 public function store_default_status_mappings_on_database(): void { 240 245 $default_mappings = $this->get_default_status_mappings(); 241 246 … … 255 260 * 256 261 * WooCommerce introduced the `OrderInternalStatus` constants in version 9.6.0. 257 * To maintain compatibility with earlier versions, string values are used as a fallback.262 * To maintain compatibility with earlier versions, string values are used as a fallback. 258 263 * This is the interface to use in next versions Automattic\WooCommerce\Enums\OrderInternalStatus 259 264 * … … 276 281 * @return array 277 282 */ 278 public function get_default_status_mappings() : array 279 { 283 public function get_default_status_mappings(): array { 280 284 $default_mappings = array( 281 285 self::WEAREPLANET_STATUS_PENDING => 'wc-pending', … … 309 313 * @return array 310 314 */ 311 public function get_legacy_default_status_mappings() : array 312 { 315 public function get_legacy_default_status_mappings(): array { 313 316 return array( 314 317 self::WEAREPLANET_STATUS_CONFIRMED => 'wearep-redirected', … … 323 326 * @return array 324 327 */ 325 public function get_all_woocommerce_statuses(): array 326 { 328 public function get_all_woocommerce_statuses(): array { 327 329 return wc_get_order_statuses(); 328 330 } … … 333 335 * @return array 334 336 */ 335 public function get_weareplanet_statuses(): array 336 { 337 public function get_weareplanet_statuses(): array { 337 338 return array( 338 339 self::WEAREPLANET_STATUS_PENDING => ucwords( self::WEAREPLANET_STATUS_PENDING ), … … 354 355 * @return string|null The corresponding WooCommerce order status or null if not found. 355 356 */ 356 private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string 357 { 357 private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string { 358 358 if ( null === $status || '' === $status ) { 359 359 return $status; … … 361 361 362 362 if ( empty( $this->settings ) ) { 363 return $status; // Return the current status if there are no mappings available.364 } 365 366 // Search in 'transaction_status' first.363 return $status; // Return the current status if there are no mappings available. 364 } 365 366 // Search in 'transaction_status' first. 367 367 foreach ( $this->settings as $setting ) { 368 if ( $setting['transaction_status'] === strtolower( $status )) {369 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.368 if ( strtolower( $status ) === $setting['transaction_status'] ) { 369 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status. 370 370 } 371 371 } 372 372 373 // Fallback to legacy mappings if no match was found.373 // Fallback to legacy mappings if no match was found. 374 374 $legacy_mappings = $this->get_legacy_default_status_mappings(); 375 375 $transaction_status_key = array_search( $status, $legacy_mappings, true ); 376 376 377 if ( ! empty( $transaction_status_key ) ) {377 if ( ! empty( $transaction_status_key ) ) { 378 378 foreach ( $this->settings as $setting ) { 379 379 if ( $setting['transaction_status'] === $transaction_status_key ) { 380 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.380 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status. 381 381 } 382 382 } 383 383 } 384 384 385 return str_replace( 'wc-', '', $status ); // Return legacy status or original (ensuring WC prefix is stripped).385 return str_replace( 'wc-', '', $status ); // Return legacy status or original (ensuring WC prefix is stripped). 386 386 } 387 387 … … 389 389 * Updates the status of a WooCommerce order based on the WeArePlanet status. 390 390 * 391 * @param WC_Order $order $order The WooCommerce order.391 * @param WC_Order $order $order The WooCommerce order. 392 392 * @param string|null $status The WeArePlanet transaction status. 393 * @param string|null $default status The WeArePlanet transaction status by default.394 * @param string $note Optional note to add when updating the status.393 * @param string|null $default_status The WeArePlanet transaction status by default. 394 * @param string $note Optional note to add when updating the status. 395 395 * @param @param bool $manual Whether this is a manual order status change. 396 396 */ 397 public function update_order_status( WC_Order $order, ?string $status, ?string $default_status, string $note = '', bool $manual = false ): void 398 { 397 public function update_order_status( 398 WC_Order $order, 399 ?string $status, 400 ?string $default_status, 401 string $note = '', 402 bool $manual = false 403 ): void { 399 404 // If status is empty. 400 if ( $status === null && $order !== null) {405 if ( null === $status && null !== $order ) { 401 406 $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); 402 407 if ( $transaction_info ) { … … 419 424 $new_status = $should_force_completed ? 'completed' : $this->map_weareplanet_status_to_woocommerce( $status ); 420 425 421 if ( ! empty( $new_status ) && !empty( $order ) ) {426 if ( ! empty( $new_status ) && ! empty( $order ) ) { 422 427 $order->update_status( $new_status, $note, $manual ); 423 428 // Apply a post-update filter to allow modifications after updating the status. … … 430 435 * and return the order status accordingly when the order is fulfill. 431 436 * 432 * @param string $status The default order status (processing or completed).433 * @param int $order_id The WooCommerce order ID.437 * @param string $status The default order status (processing or completed). 438 * @param int $order_id The WooCommerce order ID. 434 439 * @param WC_Order $order The WooCommerce order object. 435 440 * @return string The updated order status. 436 441 */ 437 public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string 438 { 442 public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string { 439 443 $change_setting_enabled = 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_CHANGE_ORDER_STATUS ); 440 444 $is_virtual_order = WC_WeArePlanet_Helper::is_order_virtual( $order ); … … 448 452 } 449 453 450 // Check if the transaction status is mapped in WooCommerce 454 // Check if the transaction status is mapped in WooCommerce. 451 455 $mapped_status = $this->map_weareplanet_status_to_woocommerce( \WeArePlanet\Sdk\Model\TransactionState::FULFILL ); 452 456 453 457 if ( ! empty( $mapped_status ) ) { 454 return $mapped_status; // Return the mapped WooCommerce status 458 return $mapped_status; // Return the mapped WooCommerce status. 455 459 } 456 460 … … 472 476 * @return string|null The mapped WooCommerce order status, or null if no mapping is found. 473 477 */ 474 public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string 475 { 478 public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string { 476 479 if ( null === $weareplanet_status || '' === $weareplanet_status ) { 477 480 return null; -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-return-handler.php
r3288388 r3740659 46 46 $order_id = absint( wp_unslash( $_GET['order_id'] ) ); //phpcs:ignore 47 47 $order = WC_Order_Factory::get_order( $order_id ); 48 $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); 48 $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // phpcs:ignore 49 49 if ( $order->get_id() === $order_id && $order->get_order_key() === $order_key ) { 50 50 switch ( $action ) { -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-subscription-gateway.php
r3463230 r3740659 97 97 public function process_scheduled_subscription_payment( $amount_to_charge, WC_Order $order ) { 98 98 try { 99 $token_data = $this->get_token_data_from_order( $order);99 $token_data = $this->get_token_data_from_order( $order ); 100 100 101 101 $token_space_id = $token_data['_weareplanet_subscription_space_id']; 102 $token_id = $token_data['_weareplanet_subscription_token_id'];102 $token_id = $token_data['_weareplanet_subscription_token_id']; 103 103 104 104 $transaction_service = WC_WeArePlanet_Service_Transaction::instance(); … … 107 107 if ( $transaction_info->get_id() > 0 ) { 108 108 $existing_transaction = $transaction_service->get_transaction( $transaction_info->get_space_id(), $transaction_info->get_id() ); 109 if ( $existing_transaction->getState() != \WeArePlanet\Sdk\Model\TransactionState::PENDING ) {109 if ( $existing_transaction->getState() !== \WeArePlanet\Sdk\Model\TransactionState::PENDING ) { 110 110 return; 111 111 } … … 162 162 if ( ! isset( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) || empty( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) ) { 163 163 throw new Exception( esc_html__( 'The WeArePlanet Space Id value is required.', 'woo-weareplanet' ) ); 164 } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) {164 } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) { 165 165 throw new Exception( esc_html__( 'The WeArePlanet Space Id needs to be in the same space as configured in the main configuration.', 'woo-weareplanet' ) ); 166 166 } … … 180 180 */ 181 181 public function update_payment_method( $update, $new_payment_method, $subscription ) { 182 if ( $this->gateway->id == $new_payment_method ) {182 if ( $this->gateway->id === $new_payment_method ) { 183 183 $update = false; 184 184 add_filter( … … 212 212 * @param WC_Order $order Order. 213 213 * @return array 214 * /215 private function get_token_data_from_order($order)216 {217 $order_id = $order->get_id();218 $token_data = [];214 * @throws Exception Exception. 215 */ 216 private function get_token_data_from_order( $order ) { 217 $order_id = $order->get_id(); 218 $token_data = array(); 219 219 $token_data['_weareplanet_subscription_space_id'] = get_post_meta( $order_id, '_weareplanet_subscription_space_id', true ); 220 220 $token_data['_weareplanet_subscription_token_id'] = get_post_meta( $order_id, '_weareplanet_subscription_token_id', true ); 221 221 222 if ( ! isset($token_data['_weareplanet_subscription_space_id']) || isset($token_data['_weareplanet_subscription_token_id']) ) {222 if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) || isset( $token_data['_weareplanet_subscription_token_id'] ) ) { 223 223 224 224 $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); 225 // In theory, each of the array elements should contain the same token and space data 226 $subscription_object = array_pop( $subscriptions);227 $subscription_meta = $subscription_object->get_meta_data();228 $token_data = [];229 $subscription_keys = [225 // In theory, each of the array elements should contain the same token and space data. 226 $subscription_object = array_pop( $subscriptions ); 227 $subscription_meta = $subscription_object->get_meta_data(); 228 $token_data = array(); 229 $subscription_keys = array( 230 230 '_weareplanet_subscription_space_id', 231 '_weareplanet_subscription_token_id' 232 ];233 234 foreach ( $subscription_meta as $meta_data ) {231 '_weareplanet_subscription_token_id', 232 ); 233 234 foreach ( $subscription_meta as $meta_data ) { 235 235 $contained_data = $meta_data->get_data(); 236 if ( in_array( $contained_data['key'], $subscription_keys ) ) {237 $token_data[ $contained_data['key']] = $contained_data['value'];236 if ( in_array( $contained_data['key'], $subscription_keys ) ) { 237 $token_data[ $contained_data['key'] ] = $contained_data['value']; 238 238 } 239 239 } 240 240 } 241 241 242 if ( ! isset($token_data['_weareplanet_subscription_space_id']) ) {242 if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) ) { 243 243 $order->update_status( 'failed', esc_html__( 'No Space Id is found.', 'woo-weareplanet' ) ); 244 throw new Exception( 'Missing space id details');245 } 246 247 if ( ! isset($token_data['_weareplanet_subscription_token_id']) ) {244 throw new Exception( 'Missing space id details' ); 245 } 246 247 if ( ! isset( $token_data['_weareplanet_subscription_token_id'] ) ) { 248 248 $order->update_status( 'failed', esc_html__( 'No Token Id is found.', 'woo-weareplanet' ) ); 249 throw new Exception( 'Missing token id');250 } 251 252 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $token_data['_weareplanet_subscription_space_id'] ) {249 throw new Exception( 'Missing token id' ); 250 } 251 252 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $token_data['_weareplanet_subscription_space_id'] ) { 253 253 $order->update_status( 'failed', esc_html__( 'The token space and the configured space are not equal.', 'woo-weareplanet' ) ); 254 throw new Exception( 'Token space does not match configured space');254 throw new Exception( 'Token space does not match configured space' ); 255 255 } 256 256 … … 297 297 public function store_gateway_result_in_globals( $result, $subscription ) { 298 298 if ( isset( $result['weareplanet'] ) ) { 299 $GLOBALS[' _wc_weareplanet_subscription_gateway_result'] = $result;299 $GLOBALS['wc_weareplanet_subscription_gateway_result'] = $result; 300 300 return array( 301 'result' => $result['result'],301 'result' => $result['result'], 302 302 'redirect' => 'wc_weareplanet_subscription_redirect', 303 303 ); … … 314 314 */ 315 315 public function create_json_response( $location, $status ) { 316 $location = basename( $location);317 if ( 'wc_weareplanet_subscription_redirect' == $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) {316 $location = basename( $location ); 317 if ( 'wc_weareplanet_subscription_redirect' === $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) { 318 318 wp_send_json( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ); 319 319 exit; -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-subscription.php
r3433358 r3740659 54 54 } 55 55 56 /** 57 * Boot the subscription integration. 58 * 59 * @return void 60 */ 56 61 public function boot() { 57 62 add_filter( … … 466 471 public function fulfill_in_progress( \WeArePlanet\Sdk\Model\Transaction $transaction, $order ) { 467 472 if ( wcs_order_contains_subscription( $order, array( 'parent', 'resubscribe', 'switch', 'renewal' ) ) ) { 468 $GLOBALS[' _wc_weareplanet_subscription_fulfill'] = true;473 $GLOBALS['wc_weareplanet_subscription_fulfill'] = true; 469 474 } 470 475 } … … 478 483 */ 479 484 public function add_valid_order_statuses_for_subscription_completion( $statuses, $order = null ) { 480 if ( isset( $GLOBALS[' _wc_weareplanet_subscription_fulfill'] ) ) {485 if ( isset( $GLOBALS['wc_weareplanet_subscription_fulfill'] ) ) { 481 486 $statuses[] = 'wearep-waiting'; 482 487 $statuses[] = 'wearep-manual'; … … 490 495 * @param WC_WeArePlanet_Entity_Transaction_Info $info Info. 491 496 * @param \WeArePlanet\Sdk\Model\Transaction $transaction Transaction. 492 * @param WC_Order $order O der.497 * @param WC_Order $order Order. 493 498 * @return WC_WeArePlanet_Entity_Transaction_Info 494 499 */ … … 565 570 */ 566 571 public function before_renewal_setup_cart( $subscriptions, $order ) { 567 $GLOBALS[' _wc_weareplanet_renewal_cart_setup'] = true;572 $GLOBALS['wc_weareplanet_renewal_cart_setup'] = true; 568 573 } 569 574 … … 576 581 */ 577 582 public function after_renewal_setup_cart( $subscriptions, $order ) { 578 $GLOBALS[' _wc_weareplanet_renewal_cart_setup'] = false;583 $GLOBALS['wc_weareplanet_renewal_cart_setup'] = false; 579 584 } 580 585 … … 586 591 */ 587 592 public function method_available_for_cart_renewal( $available ) { 588 if ( isset( $GLOBALS[' _wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['_wc_weareplanet_renewal_cart_setup'] ) {593 if ( isset( $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) { 589 594 return true; 590 595 } … … 626 631 } 627 632 } 628 629 -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-unique-id.php
r3673687 r3740659 33 33 array( 34 34 __CLASS__, 35 'copy_un qiue_id_to_order_item',35 'copy_unique_id_to_order_item', 36 36 ), 37 37 10, … … 42 42 array( 43 43 __CLASS__, 44 'copy_un qiue_id_to_order_fee',44 'copy_unique_id_to_order_fee', 45 45 ), 46 46 10, … … 51 51 array( 52 52 __CLASS__, 53 'copy_un qiue_id_to_order_shipping',53 'copy_unique_id_to_order_shipping', 54 54 ), 55 55 10, … … 81 81 * @return WC_Order_Item_Product $item item 82 82 */ 83 public static function copy_un qiue_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, ?WC_Order $order = null ) { //phpcs:ignore83 public static function copy_unique_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, WC_Order $order = null ) { //phpcs:ignore 84 84 // We do not use the cart_item_key as it is deprecated. 85 85 $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true ); … … 97 97 * @return WC_Order_Item_Shipping $item item 98 98 */ 99 public static function copy_un qiue_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, ?WC_Order $order = null ) { //phpcs:ignore99 public static function copy_unique_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, WC_Order $order = null ) { //phpcs:ignore 100 100 $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true ); 101 101 return $item; … … 112 112 * @return WC_Order_Item_Shipping $item item 113 113 */ 114 public static function copy_un qiue_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore114 public static function copy_unique_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore 115 115 $unique_id = null; 116 116 if ( $fee->amount < 0 ) { -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-webhook-handler.php
r3288388 r3740659 72 72 $raw_post_data = $wp_filesystem->get_contents( 'php://input' ); 73 73 $signature = isset( $_SERVER['HTTP_X_SIGNATURE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_SIGNATURE'] ) ) : ''; 74 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler 74 75 set_error_handler( array( __CLASS__, 'handle_webhook_errors' ) ); 75 76 try { … … 79 80 $webhook_service = WC_WeArePlanet_Service_Webhook::instance(); 80 81 81 // Handling of payloads without a signature (legacy method). 82 // TODO add config to disable strategy/use default webhooks 83 // Deprecated since 3.0.12. 82 // Handling of payloads without a signature removed since 3.4.9. 83 // Log received unsigned webhook payloads and request that webhook signature to be enabled. 84 84 if ( empty( $signature ) ) { 85 $webhook_model = $webhook_service->get_webhook_entity_for_id( $request->get_listener_entity_id() ); 86 $webhook_handler_class_name = $webhook_model->get_handler_class_name(); 87 $webhook_handler = $webhook_handler_class_name::instance(); 88 $webhook_handler->process( $request ); 85 $signature_missing_message = 'Webhook ' . $request->get_listener_entity_technical_name() 86 . ' lacked a signature. Enable payload signature and state for ' 87 . $request->get_listener_entity_technical_name() . ' webhook listener.'; 88 WooCommerce_WeArePlanet::instance()->log( $signature_missing_message, WC_Log_Levels::ERROR ); 89 echo esc_textarea( $signature_missing_message ); 89 90 } 90 91 -
weareplanet/tags/3.4.9/includes/class-wc-weareplanet-zero-gateway.php
r3321215 r3740659 1 1 <?php 2 /** 3 * Plugin Name: WeArePlanet 4 * Author: Planet Merchant Services Ltd 5 * Text Domain: weareplanet 6 * Domain Path: /languages/ 7 * 8 * WeArePlanet 9 * This plugin will add support for all WeArePlanet payments methods and connect the WeArePlanet servers to your WooCommerce webshop (https://www.weareplanet.com/). 10 * 11 * @category Class 12 * @package WeArePlanet 13 * @author Planet Merchant Services Ltd (https://www.weareplanet.com) 14 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0) 15 */ 2 16 3 17 if ( ! defined( 'ABSPATH' ) ) { … … 5 19 } 6 20 21 /** 22 * Class WC_WeArePlanet_Zero_Gateway. 23 * This class handles the zero payment gateway of WeArePlanet 24 * 25 * @class WC_WeArePlanet_Zero_Gateway 26 */ 7 27 class WC_WeArePlanet_Zero_Gateway extends WC_Payment_Gateway { 8 28 9 29 public const ZERO_PAYMENT_CONF_ID = 999999; 10 30 31 /** 32 * Constructor for the gateway. 33 */ 11 34 public function __construct() { 12 35 $this->id = 'weareplanet_zero'; … … 24 47 25 48 add_action( 26 'woocommerce_update_options_payment_gateways_' . $this->id,27 array( $this, 'process_admin_options' )49 'woocommerce_update_options_payment_gateways_' . $this->id, 50 array( $this, 'process_admin_options' ) 28 51 ); 29 52 30 53 add_filter( 31 'woocommerce_available_payment_gateways',32 array( $this, 'hide_gateways_for_zero_order_total' )54 'woocommerce_available_payment_gateways', 55 array( $this, 'hide_gateways_for_zero_order_total' ) 33 56 ); 34 57 } 35 58 59 /** 60 * Initialize form fields for the gateway settings. 61 */ 36 62 public function init_form_fields() { 37 63 $this->form_fields = array( 38 'enabled' => array(39 'title' => __( 'Enable/Disable', 'woo-weareplanet' ),40 'type' => 'checkbox',41 'label' => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ),42 'default' => 'yes',43 ),44 'title' => array(45 'title' => __( 'Title', 'woo-weareplanet' ),46 'type' => 'text',47 'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ),48 'default' => __( 'No Payment Required', 'woo-weareplanet' ),49 'desc_tip' => true,50 ),64 'enabled' => array( 65 'title' => __( 'Enable/Disable', 'woo-weareplanet' ), 66 'type' => 'checkbox', 67 'label' => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ), 68 'default' => 'yes', 69 ), 70 'title' => array( 71 'title' => __( 'Title', 'woo-weareplanet' ), 72 'type' => 'text', 73 'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ), 74 'default' => __( 'No Payment Required', 'woo-weareplanet' ), 75 'desc_tip' => true, 76 ), 51 77 ); 52 78 } 53 79 80 /** 81 * Check if the gateway is available for the current order. 82 * 83 * @return bool True if available, false otherwise. 84 */ 54 85 public function is_available() { 55 if ( isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {86 if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) {// phpcs:disable WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag. 56 87 $order_id = get_query_var( 'order-pay' ); 57 88 $order = wc_get_order( $order_id ); … … 63 94 return false; 64 95 } 65 return ( WC()->cart && WC()->cart->total == 0 ) && $this->enabled === 'yes';96 return ( WC()->cart && WC()->cart->total == 0 ) && 'yes' === $this->enabled; 66 97 } 67 98 99 /** 100 * Get the payment configuration ID for the zero payment gateway. 101 * 102 * @return int The payment configuration ID. 103 */ 68 104 public function get_payment_configuration_id() { 69 105 // This can be a fake or static ID just to satisfy the interface. … … 71 107 } 72 108 109 /** 110 * Process the payment for the order. 111 * 112 * @param int $order_id The ID of the order being processed. 113 * @return array An array containing the result and redirect URL. 114 */ 73 115 public function process_payment( $order_id ) { 74 116 $order = wc_get_order( $order_id ); … … 77 119 78 120 return array( 79 'result' => 'success',80 'redirect' => $this->get_return_url( $order ),121 'result' => 'success', 122 'redirect' => $this->get_return_url( $order ), 81 123 ); 82 124 } 83 125 126 /** 127 * Hide other payment gateways when the order total is zero. 128 * 129 * @param array $available_gateways The available payment gateways. 130 * @return array The modified list of available payment gateways. 131 */ 84 132 public function hide_gateways_for_zero_order_total( $available_gateways ) { 85 133 if ( is_admin() ) { … … 87 135 } 88 136 89 if ( isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {137 if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag. 90 138 $order_id = get_query_var( 'order-pay' ); 91 139 $order = wc_get_order( $order_id ); … … 97 145 98 146 $has_subscription = self::cart_has_subscription(); 99 if ( WC()->cart && WC()->cart->total == 0 && ! $has_subscription ) {147 if ( WC()->cart && WC()->cart->total == 0 && ! $has_subscription ) { 100 148 foreach ( $available_gateways as $gateway_id => $gateway ) { 101 if ( $gateway_id !== 'weareplanet_zero') {149 if ( 'weareplanet_zero' !== $gateway_id ) { 102 150 unset( $available_gateways[ $gateway_id ] ); 103 151 } … … 108 156 } 109 157 158 /** 159 * Check if the cart contains any subscription products. 160 * 161 * @return bool True if the cart has a subscription, false otherwise. 162 */ 110 163 public static function cart_has_subscription() { 111 164 if ( ! function_exists( 'WC' ) || ! WC()->cart ) { … … 113 166 } 114 167 115 $subscription_classes = [116 'WC_Subscription_Product',117 'WC_Product_Subscription',118 'WC_Product_Subscription_Variation',119 ];168 $subscription_classes = array( 169 'WC_Subscription_Product', 170 'WC_Product_Subscription', 171 'WC_Product_Subscription_Variation', 172 ); 120 173 121 174 foreach ( WC()->cart->get_cart() as $cart_item ) { -
weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-attribute-options.php
r3288388 r3740659 71 71 global $wpdb; 72 72 $table = $wpdb->prefix . self::get_table_name(); 73 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.73 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 74 74 $result = $wpdb->get_row( 75 75 $wpdb->prepare( … … 79 79 ARRAY_A 80 80 ); 81 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .81 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 82 82 if ( null !== $result ) { 83 83 return new self( $result ); -
weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-method-configuration.php
r3288388 r3740659 82 82 83 83 $table = $wpdb->prefix . self::get_table_name(); 84 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.84 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 85 85 $result = $wpdb->get_row( 86 86 $wpdb->prepare( … … 91 91 ARRAY_A 92 92 ); 93 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .93 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 94 94 95 95 if ( null !== $result ) { -
weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-refund-job.php
r3288388 r3740659 98 98 99 99 $table = $wpdb->prefix . self::get_table_name(); 100 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.100 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 101 101 $result = $wpdb->get_row( 102 102 $wpdb->prepare( … … 107 107 ARRAY_A 108 108 ); 109 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .109 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 110 110 if ( null !== $result ) { 111 111 return new self( $result ); -
weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-token-info.php
r3288388 r3740659 74 74 global $wpdb; 75 75 $table = $wpdb->prefix . self::get_table_name(); 76 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.76 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 77 77 $result = $wpdb->get_row( 78 78 $wpdb->prepare( … … 83 83 ARRAY_A 84 84 ); 85 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.85 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 86 86 if ( null !== $result ) { 87 87 return new self( $result ); -
weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-transaction-info.php
r3288388 r3740659 139 139 global $wpdb; 140 140 $table = $wpdb->prefix . self::get_table_name(); 141 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.141 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 142 142 $result = $wpdb->get_row( 143 143 $wpdb->prepare( … … 148 148 ARRAY_A 149 149 ); 150 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .150 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 151 151 if ( null !== $result ) { 152 152 return new self( $result ); … … 165 165 global $wpdb; 166 166 $table = $wpdb->prefix . self::get_table_name(); 167 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.167 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 168 168 $result = $wpdb->get_row( 169 169 $wpdb->prepare( … … 173 173 ARRAY_A 174 174 ); 175 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .175 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 176 176 if ( null !== $result ) { 177 177 return new self( $result ); -
weareplanet/tags/3.4.9/includes/entity/class-wc-weareplanet-entity-void-job.php
r3288388 r3740659 93 93 global $wpdb; 94 94 $table = $wpdb->prefix . self::get_table_name(); 95 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.95 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 96 96 $result = $wpdb->get_row( //phpcs:ignore 97 97 $wpdb->prepare( … … 102 102 ARRAY_A 103 103 ); 104 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .104 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 105 105 if ( null !== $result ) { 106 106 return new self( $result ); … … 120 120 121 121 $table = $wpdb->prefix . self::get_table_name(); 122 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.122 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 123 123 $result = $wpdb->get_var( 124 124 $wpdb->prepare( … … 129 129 ) 130 130 ); 131 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .131 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 132 132 return $result; 133 133 } … … 143 143 global $wpdb; 144 144 $table = $wpdb->prefix . self::get_table_name(); 145 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.145 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 146 146 $result = $wpdb->get_row( 147 147 $wpdb->prepare( … … 153 153 ARRAY_A 154 154 ); 155 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .155 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 156 156 if ( null !== $result ) { 157 157 return new self( $result ); … … 172 172 $time->sub( new DateInterval( 'PT10M' ) ); 173 173 $table = $wpdb->prefix . self::get_table_name(); 174 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.174 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 175 175 $db_results = $wpdb->get_results( 176 176 $wpdb->prepare( … … 181 181 ARRAY_A 182 182 ); 183 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .183 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 184 184 $result = array(); 185 185 if ( is_array( $db_results ) ) { -
weareplanet/tags/3.4.9/includes/packages/gift-card/class-wc-weareplanet-packages-gift-card.php
r3433358 r3740659 22 22 * This class provides constants for Gift Cards and serves as a placeholder for future improvements. 23 23 */ 24 class WC_WeArePlanet_Packages_Gift_Card 25 { 24 class WC_WeArePlanet_Packages_Gift_Card { 26 25 const WEAREPLANET_GIFT_CARD = 'Gift Card'; 27 26 } -
weareplanet/tags/3.4.9/includes/provider/class-wc-weareplanet-provider-language.php
r3288388 r3740659 89 89 */ 90 90 protected function fetch_data() { 91 // LanguageService::all() decodes languages.json into associative arrays, which the 92 // ObjectSerializer cannot map onto models, so every language ends up without codes. 93 $sdk_service = new \ReflectionClass( \WeArePlanet\Sdk\Service\LanguageService::class ); 94 $json_file = dirname( $sdk_service->getFileName() ) . '/../languages.json'; 95 if ( is_readable( $json_file ) ) { 96 $languages = json_decode( file_get_contents( $json_file ) ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents 97 if ( ! empty( $languages ) && is_array( $languages ) ) { 98 return \WeArePlanet\Sdk\ObjectSerializer::deserialize( $languages, '\WeArePlanet\Sdk\Model\RestLanguage[]' ); 99 } 100 } 91 101 $language_service = new \WeArePlanet\Sdk\Service\LanguageService( WC_WeArePlanet_Helper::instance()->get_api_client() ); 92 102 return $language_service->all(); -
weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-line-item.php
r3477965 r3740659 273 273 * 274 274 * @param WC_Coupon|WC_Order_Item_Coupon $coupon The coupon object. 275 * @param float $total_discount_amount The amount of the coupon. 275 * @param float $total_discount_amount The amount of the coupon. 276 * @param array $items The items to calculate the proportional discount for. 276 277 * @return \WeArePlanet\Sdk\Model\LineItemCreate|null The line item created or null if the coupon is not valid. 277 278 */ 278 private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = []) {279 private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = array() ) { 279 280 if ( ! $coupon instanceof WC_Coupon && ! $coupon instanceof WC_Order_Item_Coupon ) { 280 281 return array(); … … 317 318 * Calculate discount rates 318 319 * 320 * @param array $items items. 319 321 * @param float $total_discount_amount total_discount_amount. 320 322 * @return array 321 323 */ 322 324 private function calculate_discount_rates_proportionally( array $items, float $total_discount_amount ): array { 323 $tax_totals = [];325 $tax_totals = array(); 324 326 $total_amount = 0; 325 327 // If coupon line items are created from session, $items will always be an empty array. If from order, it will have said order line items. 326 $is_created_from_order = ! empty( $items);328 $is_created_from_order = ! empty( $items ); 327 329 328 330 // Check whether line items are no created from existing order. If not, line items are fetched from cart. 329 if ( ! $is_created_from_order ) {331 if ( ! $is_created_from_order ) { 330 332 $cart = WC()->cart; 331 333 $items = $cart->get_cart(); … … 340 342 // If product has no tax rates class set, then create a fake 0 rate one. 341 343 if ( empty( $tax_rates_class ) ) { 342 $tax_rates_class = [343 0 => [344 $tax_rates_class = array( 345 0 => array( 344 346 'rate' => 0, 345 ],346 ];347 ), 348 ); 347 349 } 348 350 … … 352 354 $line_total = ! $is_created_from_order ? $item['line_total'] : $item->get_total(); 353 355 $line_tax = ! $is_created_from_order ? $item['line_tax'] : $item->get_total_tax(); 354 $line_total_with_tax = floor( ($line_total + $line_tax) * 100) / 100;356 $line_total_with_tax = floor( ($line_total + $line_tax ) * 100 ) / 100; 355 357 356 358 if ( ! isset( $tax_totals[ $rate_id ] ) ) { 357 $tax_totals[ $rate_id ] = [359 $tax_totals[ $rate_id ] = array( 358 360 'total' => 0, 359 361 'rate_percentage' => $rate['rate'], 360 ];362 ); 361 363 } 362 364 363 $tax_totals[ $rate_id ]['total'] += floor( ($line_total_with_tax) * 100) / 100;365 $tax_totals[ $rate_id ]['total'] += floor( ( $line_total_with_tax ) * 100 ) / 100; 364 366 $total_amount += $line_total_with_tax; 365 367 } … … 367 369 368 370 if ( $total_amount <= 0 ) { 369 return [];370 } 371 372 $discounts = [];371 return array(); 372 } 373 374 $discounts = array(); 373 375 foreach ( $tax_totals as $rate_id => $data ) { 374 if ( $total_amount == 0) {376 if ( 0 === $total_amount ) { 375 377 // If $total_amount is 0, no proportional discounts are applied, as there is nothing to distribute. 376 378 $proportional_discount_amount = 0; 377 379 } else { 378 $proportional_discount_amount = floor( $total_discount_amount * ( $data['total'] / $total_amount ) * 100) / 100;380 $proportional_discount_amount = floor( $total_discount_amount * ( $data['total'] / $total_amount ) * 100 ) / 100; 379 381 } 380 382 381 383 if ( $proportional_discount_amount > 0 ) { 382 $discounts[] = [383 'rate_id' => $rate_id,384 'amount' => $proportional_discount_amount,385 'rate_percentage' => $data['rate_percentage'],386 ];384 $discounts[] = array( 385 'rate_id' => $rate_id, 386 'amount' => $proportional_discount_amount, 387 'rate_percentage' => $data['rate_percentage'], 388 ); 387 389 } 388 390 } … … 641 643 * Get items from backend. 642 644 * 643 * @param array $backend_items backend items.644 * @param mixed $amount amount.645 * @param array $backend_items backend items. 646 * @param mixed $amount amount. 645 647 * @param WC_Order $order order. 646 648 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] … … 660 662 * Creates the line items for the products 661 663 * 662 * @param array $backend_items backend items.664 * @param array $backend_items backend items. 663 665 * @param WC_Order $order order. 664 666 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] … … 753 755 * Returns the line items for fees. 754 756 * 755 * @param array $backend_items backend items.757 * @param array $backend_items backend items. 756 758 * @param WC_Order $order order. 757 759 * @return array … … 821 823 * Returns the line items for the shipping costs. 822 824 * 823 * @param array $backend_items backend items.825 * @param array $backend_items backend items. 824 826 * @param WC_Order $order order. 825 827 * @return array … … 999 1001 * Returns the line items from the given cart for order renewal. 1000 1002 * 1001 * @param WC_Order $order order.1002 * @param mixed $order_total Order total.1003 * @param WC_Order $order order. 1004 * @param mixed $order_total Order total. 1003 1005 * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction. 1004 1006 * … … 1023 1025 $gift_card_items = array(); 1024 1026 1025 $redeemed = WC()->session->get( '_wc_gc_giftcards', []);1027 $redeemed = WC()->session->get( '_wc_gc_giftcards', array() ); 1026 1028 1027 1029 if ( empty( $redeemed ) ) { … … 1045 1047 } 1046 1048 1047 // Receive the amount debited from the card for this order 1049 // Receive the amount debited from the card for this order. 1048 1050 $used_amount = $item['amount']; 1049 1051 … … 1052 1054 } 1053 1055 1054 // Prevent rounding errors from sdk 1056 // Prevent rounding errors from sdk. 1055 1057 $used_amount = round($used_amount, 2); 1056 1058 1057 // Create Line Items for gift cards 1059 // Create Line Items for gift cards. 1058 1060 $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate(); 1059 1061 $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) ); … … 1066 1068 $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT ); 1067 1069 1068 // Zero tax for gift card 1070 // Zero tax for gift card. 1069 1071 $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate( 1070 1072 array( … … 1084 1086 * Create gift card line items from an order object (used in backend or sync). 1085 1087 * 1086 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] 1087 */ 1088 protected function create_gift_card_line_items_from_order( $order) { 1088 * @param WC_Order $order order. 1089 * 1090 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] 1091 */ 1092 protected function create_gift_card_line_items_from_order( $order ) { 1089 1093 if ( ! function_exists( 'WC_GC' ) ) { 1090 1094 return array(); … … 1093 1097 $gift_card_items = array(); 1094 1098 1095 // Get array of strings with codes used in current order1099 // Get array of strings with codes used in current order. 1096 1100 $used_codes = WC_GC()->order->get_gift_cards( $order ); 1097 1101 … … 1100 1104 } 1101 1105 1102 $order_gift_cards = [];1103 1104 // Initialize appropriate Gift Card Objects for each code1106 $order_gift_cards = array(); 1107 1108 // Initialize appropriate Gift Card Objects for each code. 1105 1109 foreach ( $used_codes['codes'] as $item ) { 1106 1110 $order_gift_cards[] = wc_gc_get_gift_card_by_code( $item ); … … 1111 1115 } 1112 1116 1113 $items = $order->get_items( 'gift_card');1117 $items = $order->get_items( 'gift_card' ); 1114 1118 1115 1119 foreach ( $items as $giftcard_item ) { … … 1128 1132 1129 1133 $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate(); 1130 // WeArePlanet expects discounts as negative values 1134 // WeArePlanet expects discounts as negative values. 1131 1135 $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) ); 1132 1136 /* translators: %s: gift card code */ … … 1138 1142 $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT ); 1139 1143 1140 // Zero tax for gift card 1144 // Zero tax for gift card. 1141 1145 $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate( 1142 1146 array( -
weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-token.php
r3433358 r3740659 111 111 return; 112 112 } 113 114 // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists 113 114 // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists. 115 115 if ( $token_version->getPaymentConnectorConfiguration() === null ) { 116 116 return; -
weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-transaction.php
r3463230 r3740659 90 90 * @throws Exception If the API client cannot be initialized. 91 91 */ 92 public function __construct() 93 { 92 public function __construct() { 94 93 $this->api_client = WC_WeArePlanet_Helper::instance()->get_api_client(); 95 94 } … … 503 502 */ 504 503 public function get_possible_payment_methods_for_cart() { 505 $payment Configurations = $this->get_possible_payment_methods( null );506 $payment Configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;507 508 return $payment Configurations;504 $payment_configurations = $this->get_possible_payment_methods( null ); 505 $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID; 506 507 return $payment_configurations; 509 508 } 510 509 … … 521 520 */ 522 521 public function get_possible_payment_methods_for_order( WC_Order $order ) { 523 $payment Configurations = $this->get_possible_payment_methods( $order );524 $payment Configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;525 526 return $payment Configurations;522 $payment_configurations = $this->get_possible_payment_methods( $order ); 523 $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID; 524 525 return $payment_configurations; 527 526 } 528 527 … … 569 568 * @param WC_Order $order order. 570 569 * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction transaction. 571 * @param bool $set_line_items Set line items.570 * @param bool $set_line_items Set line items. 572 571 * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount. 573 572 */ … … 579 578 $transaction->setCustomerId( $this->get_customer_id() ); 580 579 $customer_note = $order->get_customer_note(); 581 if ( !empty($customer_note)) {582 $transaction->setMetaData( ['customerNotes' => $customer_note]);580 if ( ! empty( $customer_note ) ) { 581 $transaction->setMetaData( array( 'customerNotes' => $customer_note ) ); 583 582 } 584 583 $language = null; … … 786 785 * If no transaction exists, a new one is created. 787 786 * 787 * @param int|null $current_cart_id current cart id. 788 788 * @return \WeArePlanet\Sdk\Model\Transaction 789 789 * @throws Exception Exception. 790 790 */ 791 public function get_transaction_from_session( $current_cart_id = null ) {791 public function get_transaction_from_session( $current_cart_id = null ) { 792 792 793 793 if ( null === $current_cart_id ) { … … 910 910 * Load and update transaction for order. 911 911 * 912 * @param WC_Order $order order.912 * @param WC_Order $order order. 913 913 * @param WC_WeArePlanet_Entity_Transaction_Info $existing_transaction existing transaction. 914 914 * @return \WeArePlanet\Sdk\Model\Transaction|\WeArePlanet\Sdk\Model\TransactionCreate … … 1207 1207 * Set modified order line items. 1208 1208 * 1209 * @param WC_Order $order Order.1209 * @param WC_Order $order Order. 1210 1210 * @param mixed $order_total Order total. 1211 1211 * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction. … … 1221 1221 * 1222 1222 * @param WC_Order $order Order. 1223 * @param mixed $order_total Order total.1224 * @param int $token_id Token id.1223 * @param mixed $order_total Order total. 1224 * @param int $token_id Token id. 1225 1225 * 1226 1226 * @return \WeArePlanet\Sdk\Model\Transaction 1227 * @throws Exception 1228 * If the transaction being created is not valid. 1227 * @throws Exception Exception. 1229 1228 */ 1230 1229 public function create_transaction_by_renewal_order( WC_Order $order, $order_total, $token_id ) { … … 1241 1240 1242 1241 $create_transaction = apply_filters( 'wc_weareplanet_subscription_create_transaction', $create_transaction, $order ); 1243 if (!$create_transaction->valid()) { 1244 throw new Exception("The transaction you are trying to create is not valid."); 1245 } 1246 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [ 1247 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true 1248 ]); 1242 if ( ! $create_transaction->valid() ) { 1243 throw new Exception( 'The transaction you are trying to create is not valid.' ); 1244 } 1245 WC_WeArePlanet_Helper::instance()->add_headers( 1246 $this->api_client, 1247 array( 1248 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true, 1249 ) 1250 ); 1249 1251 $transaction = $this->get_transaction_service()->create( $space_id, $create_transaction ); 1250 1252 $this->update_transaction_info( $transaction, $order ); … … 1255 1257 * Creates a transaction for the given order. 1256 1258 * 1257 * @param WC_Order $order Order.1259 * @param WC_Order $order Order. 1258 1260 * @param mixed $order_total Order total. 1259 * @param int $token_id Token id.1261 * @param int $token_id Token id. 1260 1262 * @param \WeArePlanet\Sdk\Model\Transaction $transaction Transaction. 1261 1263 * … … 1275 1277 $this->set_modified_order_line_items( $order, $order_total, $pending_transaction ); 1276 1278 $pending_transaction = apply_filters( 'wc_weareplanet_subscription_update_transaction', $pending_transaction, $order ); 1277 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [ 1278 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true 1279 ]); 1279 WC_WeArePlanet_Helper::instance()->add_headers( 1280 $this->api_client, 1281 array( 1282 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true, 1283 ) 1284 ); 1280 1285 return $this->get_transaction_service()->update( $transaction->getLinkedSpaceId(), $pending_transaction ); 1281 1286 } catch ( \WeArePlanet\Sdk\VersioningException $e ) { … … 1289 1294 * Process transaction without user interaction. 1290 1295 * 1291 * @param mixed $space_id Space id.1296 * @param mixed $space_id Space id. 1292 1297 * @param mixed $transaction_id Transaction id. 1293 1298 * -
weareplanet/tags/3.4.9/includes/service/class-wc-weareplanet-service-webhook.php
r3288388 r3740659 200 200 } 201 201 } 202 $this->enforce_signed_listeners(); 202 203 } 203 204 … … 219 220 * Create a webhook listener. 220 221 * 221 * @param WC_WeArePlanet_Webhook_Entity $entity entity.222 * @param int $space_id space id.222 * @param WC_WeArePlanet_Webhook_Entity $entity entity. 223 * @param int $space_id space id. 223 224 * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url. 224 225 * … … 241 242 * Returns the existing webhook listeners. 242 243 * 243 * @param int $space_id space id.244 * @param int $space_id space id. 244 245 * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url. 245 246 * … … 343 344 return $this->webhook_url_service; 344 345 } 346 347 /** 348 * Enforces payload signatures on webhook listeners. 349 * 350 * @throws \Exception Exception. 351 */ 352 public function enforce_signed_listeners() { 353 $space_id = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ); 354 if ( empty( $space_id ) ) { 355 return; 356 } 357 $webhook_url = $this->get_webhook_url( $space_id ); 358 if ( null === $webhook_url ) { 359 return; 360 } 361 try { 362 $webhook_listeners = $this->get_webhook_listeners( $space_id, $webhook_url ); 363 } catch ( Exception $e ) { 364 WooCommerce_WeArePlanet::instance()->log( 365 'Could not load webhook listeners to enforce signing: ' . $e->getMessage(), 366 WC_Log_Levels::ERROR 367 ); 368 } 369 $webhook_service = $this->get_webhook_listener_service(); 370 foreach ( $webhook_listeners as $listener ) { 371 if ( $listener->getEnablePayloadSignatureAndState() ) { 372 continue; 373 } 374 try { 375 $update = new \WeArePlanet\Sdk\Model\WebhookListenerUpdate(); 376 $update->setId( $listener->getId() ); 377 $update->setVersion( $listener->getVersion() ); 378 $update->setEnablePayloadSignatureAndState( true ); 379 $webhook_service->update( $space_id, $update ); 380 } catch ( \Exception $e ) { 381 WooCommerce_WeArePlanet::instance()->log( 382 'Could not update webhook listeners to enforce signing: ' . $e->getMessage(), 383 WC_Log_Levels::ERROR 384 ); 385 } 386 } 387 } 345 388 } -
weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-delivery-indication-strategy.php
r3378673 r3740659 63 63 64 64 /** 65 * Meant to bridge code from deprecated processor.66 *67 * @param WC_Order $order The WooCommerce order linked to the delivery indication.68 * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object.69 * @param WC_WeArePlanet_Webhook_Request $request The webhook request.70 * @return void71 */72 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) {73 $this->process_order_related_inner( $order, $delivery_indication, $request, true );74 }75 76 /**77 65 * Processes the incoming webhook request pertaining to delivery indications. 78 66 * … … 95 83 * Additional processing on the order based on the state of the delivery indication. 96 84 * 97 * @param WC_Order $order The WooCommerce order linked to the delivery indication.85 * @param WC_Order $order The WooCommerce order linked to the delivery indication. 98 86 * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object. 99 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 100 * @param bool $legacy_mode legacy code used. 87 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 101 88 * @return void 102 89 */ 103 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {104 $entity_state = $ legacy_mode ? $delivery_indication->getState() : $request->get_state();90 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) { 91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED: -
weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-refund-strategy.php
r3378673 r3740659 62 62 63 63 /** 64 * Meant to bridge code from deprecated processor.65 *66 * @param WC_Order $order The WooCommerce order associated with the refund.67 * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object.68 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.69 * @return void70 */71 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) {72 $this->process_order_related_inner( $order, $refund, $request, true );73 }74 75 /**76 64 * Processes the incoming webhook request related to refunds. 77 65 * … … 97 85 * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object. 98 86 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 99 * @param bool $legacy_mode legacy code used.100 87 * @return void 101 88 */ 102 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {89 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) { 103 90 /* @var \WeArePlanet\Sdk\Model\Refund $refund */ 104 $entity_state = $ legacy_mode ? $refund->getState() : $request->get_state();91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\RefundState::FAILED: -
weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-completion-strategy.php
r3378673 r3740659 63 63 64 64 /** 65 * Meant to bridge code from deprecated processor.66 *67 * @param WC_Order $order The WooCommerce order linked to the completion.68 * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object.69 * @param WC_WeArePlanet_Webhook_Request $request The webhook request.70 * @return void71 */72 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) {73 $this->process_order_related_inner( $order, $completion, $request, true );74 }75 76 /**77 65 * Processes the incoming webhook request pertaining to transaction completions. 78 66 * … … 98 86 * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object. 99 87 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 100 * @param bool $legacy_mode legacy code used. 101 * @return void 102 */ 103 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) { 104 $entity_state = $legacy_mode ? $completion->getState() : $request->get_state(); 88 * @return void 89 */ 90 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) { 91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\TransactionCompletionState::FAILED: -
weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-invoice-strategy.php
r3378673 r3740659 63 63 64 64 /** 65 * Meant to bridge code from deprecated processor.66 *67 * @param WC_Order $order The WooCommerce order linked to the invoice.68 * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object.69 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.70 * @return void71 */72 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) {73 $this->process_order_related_inner( $order, $transaction_invoice, $request, true );74 }75 76 /**77 65 * Processes the incoming webhook request pertaining to transaction invoices. 78 66 * … … 95 83 * Additional processing on the order based on the state of the transaction invoice. 96 84 * 97 * @param WC_Order $order The WooCommerce order linked to the invoice.85 * @param WC_Order $order The WooCommerce order linked to the invoice. 98 86 * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object. 99 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 100 * @param bool $legacy_mode legacy code used. 87 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 101 88 * @return void 102 89 */ 103 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {104 $entity_state = $ legacy_mode ? $transaction_invoice->getState() : $request->get_state();90 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) { 91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\TransactionInvoiceState::DERECOGNIZED: -
weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-strategy.php
r3598699 r3740659 38 38 39 39 /** 40 * Meant to bridge code from deprecated processor.41 *42 * @param WC_Order $order order.43 * @param mixed $transaction transaction.44 * @return mixed The result of the processing.45 */46 public function bridge_process_order_related_inner( WC_Order $order, $transaction ) {47 $this->process_order_related_inner( $order, $transaction, true );48 }49 50 /**51 40 * Process the webhook request. 52 41 * 53 * @param \WeArePlanet\Sdk\Model\Transaction $transaction The webhook request object.42 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 54 43 * @return mixed The result of the processing. 55 44 */ … … 58 47 $entity = $this->load_entity( $request ); 59 48 60 // retry orphaned transaction, fall back to merchant reference49 // Retry orphaned transaction, fall back to merchant reference. 61 50 if ( ( false === $order || ! $order->get_id() ) && $entity ) { 62 51 $merchant_ref = $entity->getMerchantReference(); … … 68 57 if ( false != $order && $order->get_id() ) { 69 58 $this->process_order_related_inner( $order, $entity ); 70 if ( $request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {59 if ( $request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED ) { 71 60 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() ); 72 61 } … … 79 68 * @param WC_Order $order order. 80 69 * @param mixed $transaction transaction. 81 * @param bool $legacy_mode legacy code used.82 70 * @return void 83 71 * @throws Exception Exception. 84 72 */ 85 protected function process_order_related_inner( WC_Order $order, $transaction , $legacy_mode = false) {73 protected function process_order_related_inner( WC_Order $order, $transaction ) { 86 74 if ( strpos( $order->get_payment_method(), 'weareplanet' ) === false ) { 87 75 return; … … 108 96 $this->authorize( $transaction, $order ); 109 97 $this->fulfill( $transaction, $order ); 110 if ( $legacy_mode ) {111 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );112 }113 98 WC_WeArePlanet_Helper::set_virtual_zero_total_orders_to_complete( $order ); 114 99 WC_WeArePlanet_Helper::update_order_status_for_preorder_if_needed( $order ); … … 127 112 WC_WeArePlanet_Service_Transaction::instance()->update_transaction_info( $transaction, $order ); 128 113 } 129 130 if ( $legacy_mode ) {131 // This is edge case for deferred payment methods132 $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );133 if ($transaction_info->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {134 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );135 }136 }137 114 } 138 115 … … 141 118 * 142 119 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 143 * @param WC_Order $order order.120 * @param WC_Order $order order. 144 121 * @return void 145 122 */ … … 162 139 * 163 140 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 164 * @param \WC_Order $order order.141 * @param \WC_Order $order order. 165 142 */ 166 143 protected function authorize( \WeArePlanet\Sdk\Model\Transaction $transaction, WC_Order $order ) { … … 181 158 * 182 159 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 183 * @param WC_Order $order order.160 * @param WC_Order $order order. 184 161 * @return void 185 162 */ … … 200 177 * 201 178 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 202 * @param WC_Order $order order.179 * @param WC_Order $order order. 203 180 * @return void 204 181 */ … … 217 194 * 218 195 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 219 * @param WC_Order $order order.196 * @param WC_Order $order order. 220 197 * @return void 221 198 */ … … 231 208 // Custom order statuses mapped. 232 209 apply_filters( 'weareplanet_wc_status_for_transaction', 'confirmed' ), 233 apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' ) 210 apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' ), 234 211 ); 235 212 if ( in_array( $order->get_status( 'edit' ), $valid_order_statuses ) ) { … … 244 221 * 245 222 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 246 * @param WC_Order $order order.223 * @param WC_Order $order order. 247 224 * @return void 248 225 */ … … 274 251 * 275 252 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 276 * @param WC_Order $order order.253 * @param WC_Order $order order. 277 254 * @return void 278 255 */ -
weareplanet/tags/3.4.9/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-void-strategy.php
r3378673 r3740659 66 66 67 67 /** 68 * Meant to bridge code from deprecated processor.69 *70 * @param WC_Order $order The WooCommerce order associated with the void request.71 * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object.72 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.73 * @return void74 */75 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) {76 $this->process_order_related_inner( $order, $void, $request, true );77 }78 79 /**80 68 * Processes the incoming webhook request related to transaction voids. 81 69 * … … 101 89 * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object. 102 90 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 103 * @param bool $legacy_mode legacy code used.104 91 * @return void 105 92 */ 106 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {107 $entity_state = $ legacy_mode ? $void->getState() : $request->get_state();93 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) { 94 $entity_state = $request->get_state(); 108 95 switch ( $entity_state ) { 109 96 case \WeArePlanet\Sdk\Model\TransactionVoidState::FAILED: -
weareplanet/tags/3.4.9/readme.txt
r3676036 r3740659 3 3 Tags: payment, WeArePlanet, e-commerce, invoice, psp 4 4 Requires at least: 6.0 5 Tested up to: 7. 06 Stable tag: 3.4. 85 Tested up to: 7.1.2 6 Stable tag: 3.4.9 7 7 License: Apache-2.0 8 8 License URI: http://www.apache.org/licenses/LICENSE-2.0 … … 22 22 23 23 Additional documentation for this plugin is available: 24 [here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4. 8/docs/en/documentation.html).24 [here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html). 25 25 26 26 == Source code and build process == … … 204 204 == Changelog == 205 205 206 = 3.4.8 - September 1 2026 = 207 - [BugFix] Fixed missing assets 206 = 3.4.9 - October 7 2026 = 207 - [Feature] Tested against Wordpress 7.1.2 208 - [Bugfix] Fixed issue where translations for payment methods were incorrect 208 209 - [Tested Against] PHP 8.4.20 209 - [Tested Against] Wordpress 7 210 - [Tested Against] Woocommerce 11. 0.1211 - [Tested Against] PHP SDK 4.9. 1210 - [Tested Against] Wordpress 7.1.2 211 - [Tested Against] Woocommerce 11.2.0 212 - [Tested Against] PHP SDK 4.9.2 -
weareplanet/tags/3.4.9/views/admin-notices/subscription-plugin-deactivate.php
r3433358 r3740659 19 19 ?> 20 20 <div class="error notice notice-error"> 21 <p>22 <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?>23 </p>21 <p> 22 <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?> 23 </p> 24 24 </div> -
weareplanet/tags/3.4.9/views/admin-settings/html-admin-page-order-statuses.php
r3463230 r3740659 25 25 <thead> 26 26 <tr> 27 <?php foreach ( $order_statuses_columns as $ status_key => $heading ) : ?>28 <th class="<?php echo esc_attr( $ status_key ); ?>"><?php echo esc_html( $heading ); ?></th>27 <?php foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) : ?> 28 <th class="<?php echo esc_attr( $weareplanet_status_key ); ?>"><?php echo esc_html( $weareplanet_heading ); ?></th> 29 29 <?php endforeach; ?> 30 30 <th /> … … 55 55 <article> 56 56 <form action="" method="post"> 57 <input type="hidden" name="key" value="{{{ data.key }}}" />57 <input type="hidden" name="key" value="{{{ data.key }}}" /> 58 58 <?php 59 foreach ( $order_statuses_columns as $ status_key => $heading ) {60 echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $ status_key ) . '">';61 switch ( $ status_key ) {59 foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) { 60 echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $weareplanet_status_key ) . '">'; 61 switch ( $weareplanet_status_key ) { 62 62 case 'weareplanet-order-status-key': 63 63 ?> 64 64 <div class="view"> 65 <?php echo esc_html( $ heading ); ?> *65 <?php echo esc_html( $weareplanet_heading ); ?> * 66 66 </div> 67 67 <div class="edit"> … … 74 74 placeholder="<?php esc_attr_e( 'e.g. awaiting', 'woo-weareplanet' ); ?>" /> 75 75 </label> 76 <small id="charCount" style="color: gray;"></small>76 <small id="charCount" style="color: gray;"></small> 77 77 </div> 78 78 <div class="weareplanet-order-statuses-modal-help-text wc-shipping-class-modal-help-text"><?php esc_html_e( 'Give your custom status a name for easy identification', 'woo-weareplanet' ); ?></div> … … 102 102 <tr data-id="{{ data.key }}"> 103 103 <?php 104 foreach ( $order_statuses_columns as $ status_key => $heading ) {105 echo '<td class="' . esc_attr( $ status_key ) . '">';106 switch ( $ status_key ) {104 foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) { 105 echo '<td class="' . esc_attr( $weareplanet_status_key ) . '">'; 106 switch ( $weareplanet_status_key ) { 107 107 case 'weareplanet-order-status-key': 108 108 ?> -
weareplanet/tags/3.4.9/weareplanet-sdk/composer.json
r3673687 r3740659 1 1 { 2 2 "name": "weareplanet/sdk", 3 "version": "4.9. 1",3 "version": "4.9.2", 4 4 "description": "WeArePlanet SDK for PHP", 5 5 "keywords": [ -
weareplanet/tags/3.4.9/weareplanet-sdk/lib/ApiClient.php
r3673687 r3740659 49 49 */ 50 50 private $defaultHeaders = [ 51 'x-meta-sdk-version' => "4.9. 1",51 'x-meta-sdk-version' => "4.9.2", 52 52 'x-meta-sdk-language' => 'php', 53 53 'x-meta-sdk-provider' => "WeArePlanet", … … 59 59 * @var string 60 60 */ 61 private $userAgent = 'PHP-Client/4.9. 1/php';61 private $userAgent = 'PHP-Client/4.9.2/php'; 62 62 63 63 /** -
weareplanet/tags/3.4.9/weareplanet-sdk/lib/Configuration.php
r3673687 r3740659 81 81 * @var string 82 82 */ 83 protected $userAgent = 'WeArePlanet\Sdk/4.9. 1/php';83 protected $userAgent = 'WeArePlanet\Sdk/4.9.2/php'; 84 84 85 85 /** … … 389 389 $report .= ' OS: ' . php_uname() . PHP_EOL; 390 390 $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; 391 $report .= ' OpenAPI Spec Version: 4.9. 1' . PHP_EOL;392 $report .= ' SDK Package Version: 4.9. 1' . PHP_EOL;391 $report .= ' OpenAPI Spec Version: 4.9.2' . PHP_EOL; 392 $report .= ' SDK Package Version: 4.9.2' . PHP_EOL; 393 393 $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; 394 394 -
weareplanet/tags/3.4.9/weareplanet-sdk/lib/Model/AbstractWebhookListenerUpdate.php
r3673687 r3740659 49 49 */ 50 50 protected static $swaggerTypes = [ 51 'enable_payload_signature_and_state' => 'bool', 51 52 'entity_states' => 'string[]', 52 53 'name' => 'string', … … 61 62 */ 62 63 protected static $swaggerFormats = [ 64 'enable_payload_signature_and_state' => null, 63 65 'entity_states' => null, 64 66 'name' => null, … … 74 76 */ 75 77 protected static $attributeMap = [ 78 'enable_payload_signature_and_state' => 'enablePayloadSignatureAndState', 76 79 'entity_states' => 'entityStates', 77 80 'name' => 'name', … … 86 89 */ 87 90 protected static $setters = [ 91 'enable_payload_signature_and_state' => 'setEnablePayloadSignatureAndState', 88 92 'entity_states' => 'setEntityStates', 89 93 'name' => 'setName', … … 98 102 */ 99 103 protected static $getters = [ 104 'enable_payload_signature_and_state' => 'getEnablePayloadSignatureAndState', 100 105 'entity_states' => 'getEntityStates', 101 106 'name' => 'getName', … … 121 126 public function __construct(?array $data = null) 122 127 { 128 129 $this->container['enable_payload_signature_and_state'] = isset($data['enable_payload_signature_and_state']) ? $data['enable_payload_signature_and_state'] : null; 123 130 124 131 $this->container['entity_states'] = isset($data['entity_states']) ? $data['entity_states'] : null; -
weareplanet/tags/3.4.9/weareplanet-sdk/test/ApiClientTest.php
r3673687 r3740659 145 145 146 146 // Check SDK default header values. 147 $this->assertEquals($headers['x-meta-sdk-version'], "4.9. 1");147 $this->assertEquals($headers['x-meta-sdk-version'], "4.9.2"); 148 148 $this->assertEquals($headers['x-meta-sdk-language'], 'php'); 149 149 $this->assertEquals($headers['x-meta-sdk-provider'], "WeArePlanet"); -
weareplanet/tags/3.4.9/weareplanet.php
r3676036 r3740659 4 4 * Plugin URI: https://wordpress.org/plugins/woo-weareplanet 5 5 * Description: Process WooCommerce payments with WeArePlanet. 6 * Version: 3.4. 86 * Version: 3.4.9 7 7 * Author: Planet Merchant Services Ltd 8 8 * Author URI: https://www.weareplanet.com … … 16 16 * License: Apache-2.0 17 17 * License URI: http://www.apache.org/licenses/LICENSE-2.0 18 * 19 * @package WeArePlanet 18 20 */ 21 19 22 if ( ! defined( 'ABSPATH' ) ) { 20 23 exit(); // Exit if accessed directly. … … 43 46 const WEAREPLANET_CK_DISABLE_PENDING_EMAIL = 'wc_weareplanet_disable_pending_email'; 44 47 const WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING = 'wc_weareplanet_enable_custom_status_mapping'; 45 const WEAREPLANET_UPGRADE_VERSION = '3.1.1'; 46 const WC_MAXIMUM_VERSION = '11. 0.1';48 const WEAREPLANET_UPGRADE_VERSION = '3.1.1'; // Leave this number alone! It was a fix for a problem introduced at this version. 49 const WC_MAXIMUM_VERSION = '11.2.0'; 47 50 const REQUIRED_WC_SUBSCRIPTION_VERSION = '2.5'; 48 51 … … 52 55 * @var string 53 56 */ 54 private $version = '3.4. 8';57 private $version = '3.4.9'; 55 58 56 59 /** … … 89 92 } 90 93 94 /** 95 * Define constant if not already set. 96 */ 91 97 public function boot() { 92 98 $this->init(); 93 99 } 94 100 101 /** 102 * Initialize the plugin. 103 */ 95 104 private function init() { 96 105 $this->includes(); … … 159 168 array( 160 169 'WooCommerce_WeArePlanet', 161 'migrate_plugin_data_on_activation' 170 'migrate_plugin_data_on_activation', 162 171 ) 163 172 ); … … 393 402 */ 394 403 public static function get_installed_plugin_version( $plugin_slug ) { 395 if ( !function_exists( 'get_plugins' ) ) {404 if ( ! function_exists( 'get_plugins' ) ) { 396 405 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 397 406 } … … 400 409 foreach ( $all_plugins as $plugin_path => $plugin_info ) { 401 410 if ( strpos( $plugin_path, $plugin_slug ) !== false ) { 402 return $plugin_info[ 'Version'];411 return $plugin_info['Version']; 403 412 } 404 413 } … … 457 466 458 467 global $wpdb; 459 $options_to_migrate = [468 $options_to_migrate = array( 460 469 $old_option_prefix . WC_WeArePlanet_Migration::WEAREPLANET_CK_DB_VERSION, 461 470 $old_option_prefix . WC_WeArePlanet_Service_Manual_Task::WEAREPLANET_CONFIG_KEY, … … 472 481 $old_option_prefix . self::WEAREPLANET_CK_CHANGE_ORDER_STATUS, 473 482 $old_option_prefix . self::WC_MAXIMUM_VERSION, 474 ];483 ); 475 484 476 485 // If the old plugin options exist, perform the migration. … … 487 496 add_option( $new_option_name, $option_value ); 488 497 } 489 // Delete the old option. 490 //delete_option( $option_name );. 498 // Delete the old option: delete_option( $option_name );. 491 499 } 492 500 } … … 498 506 * 499 507 * @param object $upgrader_object The upgrader object. 500 * @param array $options The options array.508 * @param array $options The options array. 501 509 */ 502 510 public static function migrate_plugin_data_after_update( $upgrader_object, $options ) { … … 530 538 531 539 // WordPress.org will auto-load translations. No need to call load_plugin_textdomain(). 532 // $this->load_plugin_textdomain(); 533 add_action('plugins_loaded', function () { 534 if (class_exists('WC_Payment_Gateway')) { 535 require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php'; 536 add_filter( 537 'woocommerce_payment_gateways', 538 array( 539 WooCommerce_WeArePlanet::instance(), 540 'add_gateways', 541 ) 542 ); 543 } 544 }, 20); 540 // $this->load_plugin_textdomain();. 541 add_action( 542 'plugins_loaded', 543 function () { 544 if ( class_exists( 'WC_Payment_Gateway' ) ) { 545 require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php'; 546 add_filter( 547 'woocommerce_payment_gateways', 548 array( 549 WooCommerce_WeArePlanet::instance(), 550 'add_gateways', 551 ) 552 ); 553 } 554 }, 555 20 556 ); 545 557 add_action( 546 558 'plugins_loaded', … … 603 615 add_filter( 604 616 'woocommerce_cart_needs_payment', 605 function ($value, $object) {617 function ( $value, $object ) { 606 618 return true; 607 }, 10, 2 619 }, 620 10, 621 2 608 622 ); 609 623 add_filter( 610 'woocommerce_order_needs_payment',611 function($value, $order) {624 'woocommerce_order_needs_payment', 625 function ( $value, $order ) { 612 626 $order_data = $order->get_data(); 613 if ( substr_count($order_data['payment_method'], "weareplanet")) {627 if ( substr_count( $order_data['payment_method'], 'weareplanet' ) ) { 614 628 // If the order is using our payment method, we want to process it 615 629 // even if the value of the transaction is 0, which woocommerce by default 616 630 // process it without payment gateway. 617 631 $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); 618 if ( in_array( 619 $transaction_info->get_state(), 620 array( 621 \WeArePlanet\Sdk\Model\TransactionState::FULFILL, 622 \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED, 623 \WeArePlanet\Sdk\Model\TransactionState::COMPLETED, 624 \WeArePlanet\Sdk\Model\TransactionState::FAILED, 625 \WeArePlanet\Sdk\Model\TransactionState::DECLINE, 626 ), 627 true 628 ) ) { 632 if ( 633 in_array( 634 $transaction_info->get_state(), 635 array( 636 \WeArePlanet\Sdk\Model\TransactionState::FULFILL, 637 \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED, 638 \WeArePlanet\Sdk\Model\TransactionState::COMPLETED, 639 \WeArePlanet\Sdk\Model\TransactionState::FAILED, 640 \WeArePlanet\Sdk\Model\TransactionState::DECLINE, 641 ), 642 true 643 ) 644 ) { 629 645 return false; 630 646 } … … 632 648 } 633 649 return $value; 634 }, 10, 2 650 }, 651 10, 652 2 635 653 ); 636 654 add_action( … … 772 790 ); 773 791 774 add_filter('the_content', function($content) { 775 if ( is_checkout() && ! is_order_received_page() ) { 776 // When in checkout, we inject the list of payment methods in the HTML. 777 // The goal here is to speed up the process of registering the payment methods. 778 $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods(); 779 $json_data = json_encode( $payment_methods ); 780 $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>'; 781 } 782 783 return $content; 784 }); 792 add_filter( 793 'the_content', 794 function ( $content ) { 795 if ( is_checkout() && ! is_order_received_page() ) { 796 // When in checkout, we inject the list of payment methods in the HTML. 797 // The goal here is to speed up the process of registering the payment methods. 798 $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods(); 799 $json_data = json_encode( $payment_methods ); 800 $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>'; 801 } 802 803 return $content; 804 } 805 ); 785 806 } 786 807 … … 806 827 * @return bool 807 828 */ 808 public static function is_subscriptions_compatible(): bool {829 public static function is_subscriptions_compatible(): bool { 809 830 $plugin_name = 'woocommerce-subscriptions.php'; 810 831 $woocommerce_subscriptions_directory = self::find_plugin_path( $plugin_name ); … … 825 846 * Looks for legacy subscription plugin's directory. 826 847 * 848 * @param string $plugin_name The plugin file name to search for. 827 849 * @return string|null 828 850 */ … … 867 889 } 868 890 869 /**870 * Register order statuses.871 *872 * @return void873 */874 public function register_order_statuses() {875 $common_args = array(876 'public' => true,877 'exclude_from_search' => false,878 'show_in_admin_all_list' => true,879 'show_in_admin_status_list' => true,880 );881 882 register_post_status(883 'wc-wearep-redirected',884 array_merge(891 /** 892 * Register order statuses. 893 * 894 * @return void 895 */ 896 public function register_order_statuses() { 897 $common_args = array( 898 'public' => true, 899 'exclude_from_search' => false, 900 'show_in_admin_all_list' => true, 901 'show_in_admin_status_list' => true, 902 ); 903 904 register_post_status( 905 'wc-wearep-redirected', 906 array_merge( 885 907 $common_args, 886 908 array( … … 918 940 * Add order statuses. 919 941 * 920 * @param mixed $order_statuses order statuses.921 * @return mixed922 */923 public function add_order_statuses( $order_statuses ) {924 $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' );925 $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' );926 $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' );927 928 return $order_statuses;942 * @param mixed $order_statuses order statuses. 943 * @return mixed 944 */ 945 public function add_order_statuses( $order_statuses ) { 946 $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' ); 947 $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' ); 948 $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' ); 949 950 return $order_statuses; 929 951 } 930 952 … … 936 958 * @return mixed 937 959 */ 938 public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore939 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {940 $statuses[] = 'wearep-redirected';941 }942 943 return $statuses;944 }960 public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore 961 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) { 962 $statuses[] = 'wearep-redirected'; 963 } 964 965 return $statuses; 966 } 945 967 946 968 /** … … 964 986 } 965 987 966 // Sanitize input properly.967 $changes = sanitize_text_field( wp_unslash( $_POST['changes'] ));988 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- $_POST['changes'] array is unslashed with wp_unslash(). We sanitize each field individually with array_map( 'sanitize_text_field' ) and sanitize_key() below. 989 $changes = wp_unslash( $_POST['changes'] ); 968 990 969 991 // Get the first key inside the 'changes' array. 970 992 $first_key = key( $changes ); 971 $data = $_POST['changes'][$first_key]; 993 if ( ! isset( $changes[ $first_key ] ) || ! is_array( $changes[ $first_key ] ) ) { 994 wp_send_json_error( 'invalid_data' ); 995 wp_die(); 996 } 997 $raw_data = $changes[ $first_key ]; 998 $data = array_map( 'sanitize_text_field', $raw_data ); 999 $first_key = sanitize_key( $first_key ); 972 1000 973 1001 if ( isset( $data['key'] ) ) { 974 $label = str_replace( ['-', '_'], ' ', sanitize_text_field( $data['key'] ) );1002 $label = str_replace( array( '-', '_' ), ' ', sanitize_text_field( $data['key'] ) ); 975 1003 976 1004 // Normalize the key by replacing spaces and dashes with underscores. 977 $sanitized_key_underscore = str_replace( [' ', '-'], '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key );978 $sanitized_key_hyphen = str_replace( [' ', '_'], '-', $first_key );1005 $sanitized_key_underscore = str_replace( array( '-', '_' ), '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key ); 1006 $sanitized_key_hyphen = str_replace( array( ' ', '_' ), '-', $first_key ); 979 1007 980 1008 // Construct the full option name with the required prefix. … … 984 1012 update_option( $custom_order_name, $custom_order_value ); 985 1013 986 register_post_status( $custom_order_value, array( 987 'label' => $label, 988 'public' => true, 989 'show_in_admin_status_list' => true, 990 'show_in_admin_all_list' => true, 991 'exclude_from_search' => false, 992 'label_count' => array( 993 'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 994 'plural' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 1014 wp_cache_delete( 'weareplanet_custom_order_statuses', 'weareplanet' ); 1015 1016 register_post_status( 1017 $custom_order_value, 1018 array( 1019 'label' => $label, 1020 'public' => true, 1021 'show_in_admin_status_list' => true, 1022 'show_in_admin_all_list' => true, 1023 'exclude_from_search' => false, 1024 'label_count' => array( 1025 'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 1026 'plural' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 1027 ) 995 1028 ) 996 ) );1029 ); 997 1030 998 1031 // Send a success response with the saved order status details. 999 wp_send_json_success([ 1000 'message' => 'Success', 1001 'order_status' => [ 1002 'key' => $custom_order_value, // The full key with the prefix. 1003 'label' => ucfirst( $label ), // As received from the form data. 1004 'type' => __( 'custom' , 'woo-weareplanet' ) 1005 ] 1006 ]); 1032 wp_send_json_success( 1033 array( 1034 'message' => 'Success', 1035 'order_status' => array( 1036 'key' => $custom_order_value, // The full key with the prefix. 1037 'label' => ucfirst( $label ), // As received from the form data. 1038 'type' => __( 'custom', 'woo-weareplanet' ), 1039 ), 1040 ) 1041 ); 1007 1042 } else { 1008 1043 wp_send_json_error( 'invalid_data' ); … … 1033 1068 1034 1069 $sanitized_key = sanitize_text_field( wp_unslash( $_POST['key'] ) ); 1035 1036 // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_". 1037 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%'; 1038 $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1070 $cache_group = 'weareplanet'; 1071 1072 $is_used_cache_key = 'weareplanet_status_in_use_' . md5( $sanitized_key ); 1073 $is_used = wp_cache_get( $is_used_cache_key, $cache_group ); 1074 1075 if ( $is_used === false ) { 1076 // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_". 1077 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%'; 1078 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 1079 $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1080 wp_cache_set( $is_used_cache_key, $is_used, $cache_group, HOUR_IN_SECONDS ); 1081 } 1039 1082 1040 1083 if ( $is_used > 0 ) { 1041 1084 // The status is in use, so do not delete it. 1042 wp_send_json_error( ['message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )], 400 ); 1043 } 1044 1045 // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_". 1046 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; 1047 $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1085 wp_send_json_error( 1086 array( 1087 'message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ), 1088 'key' => ucfirst( $sanitized_key ), 1089 ), 1090 400 1091 ); 1092 } 1093 1094 $option_name_cache_key = 'weareplanet_status_option_name_' . md5( $sanitized_key ); 1095 $custom_order_status_name = wp_cache_get( $option_name_cache_key, $cache_group ); 1096 1097 if ( $custom_order_status_name === false ) { 1098 // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_". 1099 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; 1100 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 1101 $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1102 wp_cache_set( $option_name_cache_key, $custom_order_status_name, $cache_group, HOUR_IN_SECONDS ); 1103 } 1048 1104 1049 1105 // Remove from wp_options. 1050 1106 delete_option( $custom_order_status_name ); 1051 1107 1108 wp_cache_delete( $is_used_cache_key, $cache_group ); 1109 wp_cache_delete( $option_name_cache_key, $cache_group ); 1110 wp_cache_delete( 'weareplanet_custom_order_statuses', $cache_group ); 1111 1052 1112 // Return success response. 1053 wp_send_json_success( ['message' => __( 'Deleted successfully', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )] ); 1113 wp_send_json_success( 1114 array( 1115 'message' => __( 'Deleted successfully', 'woo-weareplanet' ), 1116 'key' => ucfirst( $sanitized_key ), 1117 ) 1118 ); 1054 1119 } 1055 1120 … … 1060 1125 */ 1061 1126 public function set_device_id_cookie() { 1062 if (!headers_sent()) {1127 if ( ! headers_sent() ) { 1063 1128 $value = WC_WeArePlanet_Unique_Id::get_uuid(); 1064 1129 if ( isset( $_COOKIE['wc_weareplanet_device_id'] ) && ! empty( $_COOKIE['wc_weareplanet_device_id'] ) ) { … … 1122 1187 * @return false|mixed 1123 1188 */ 1124 public function order_editable_check( $allowed, WC_Order $order = null ) {1189 public function order_editable_check( $allowed, ?WC_Order $order = null ) { 1125 1190 if ( is_null( $order ) ) { 1126 1191 return $allowed; … … 1139 1204 * @return mixed 1140 1205 */ 1141 public function valid_order_status_for_completion( $statuses, WC_Order $order = null ) { //phpcs:ignore1206 public function valid_order_status_for_completion( $statuses, ?WC_Order $order = null ) { //phpcs:ignore 1142 1207 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) { 1143 1208 $statuses[] = 'wearep-waiting'; … … 1192 1257 foreach ( $method_configurations as $configuration ) { 1193 1258 $gateway = new WC_WeArePlanet_Gateway( $configuration ); 1194 $methods[] = apply_filters( 'wc_weareplanet_enhance_gateway', $gateway);1259 $methods[] = apply_filters( 'wc_weareplanet_enhance_gateway', $gateway ); 1195 1260 } 1196 1261 } catch ( \WeArePlanet\Sdk\ApiException $e ) { … … 1352 1417 */ 1353 1418 public function register_checkout_error_msg() { 1354 if ( ! isset( WC()->session ) ) return false; 1419 if ( ! isset( WC()->session ) ) { 1420 return false; 1421 } 1355 1422 $msg = WC()->session->get( 'weareplanet_failure_message', null ); 1356 1423 if ( ! empty( $msg ) ) { … … 1380 1447 */ 1381 1448 protected function define( $name, $value ) { 1449 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound -- $name is a local, not a global parameter 1382 1450 if ( ! defined( $name ) ) { 1383 1451 define( $name, $value ); 1384 1452 } 1453 // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound 1385 1454 } 1386 1455 … … 1588 1657 } 1589 1658 1590 add_action( 'woocommerce_loaded', function () { 1591 WooCommerce_WeArePlanet::instance()->boot(); 1592 add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' ); 1593 }); 1659 add_action( 1660 'woocommerce_loaded', 1661 function () { 1662 WooCommerce_WeArePlanet::instance()->boot(); 1663 add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' ); 1664 } 1665 ); 1594 1666 1595 1667 function WC_WeArePlanet_Blocks_Support() { //phpcs:ignore -
weareplanet/trunk/changelog.txt
r3676036 r3740659 963 963 - [Tested Against] PHP SDK 4.8.0 964 964 965 = 3.4. 8- July 22nd 2025 =965 = 3.4.9 - July 22nd 2025 = 966 966 - [Bugfix] Fix class loading order issues 967 967 - [Bugfix] Fix problem with multisite not installing tables when plugin is network activated … … 979 979 - [Hotfix] Rollback to stable version 980 980 981 = 3.4. 8- July 29nd 2025 =981 = 3.4.9 - July 29nd 2025 = 982 982 - [Bugfix] Fix class loading order issues 983 983 - [Bugfix] Fix problem with multisite not installing tables when plugin is network activated … … 992 992 - [Tested Against] PHP SDK 4.8.0 993 993 994 = 3.4. 8- July 30th 2025 =994 = 3.4.9 - July 30th 2025 = 995 995 - [Bugfix] Fix issue with calling a renamed function 996 996 - [Tested Against] PHP 8.2 … … 1115 1115 - [Tested Against] PHP SDK 4.9.1 1116 1116 1117 = 3.4.9 - October 7 2026 = 1118 - [Feature] Tested against Wordpress 7.1.2 1119 - [Bugfix] Fixed issue where translations for payment methods were incorrect 1120 - [Tested Against] PHP 8.4.20 1121 - [Tested Against] Wordpress 7.1.2 1122 - [Tested Against] Woocommerce 11.2.0 1123 - [Tested Against] PHP SDK 4.9.2 1124 -
weareplanet/trunk/docs/en/documentation.html
r3676036 r3740659 24 24 </li> 25 25 <li> 26 <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4. 8/">26 <a href="https://github.com/weareplanet/woocommerce/releases/tag/3.4.9/"> 27 27 Source 28 28 </a> … … 397 397 <td class="tableblock halign-left valign-top"><p class="tableblock">Device/session ID for fraud prevention during payment. Set/updated by the plugin on the WordPress init hook.</p></td> 398 398 </tr> 399 <tr>400 <td class="tableblock halign-left valign-top"><p class="tableblock"><code>weareplanetNewUi</code></p></td>401 <td class="tableblock halign-left valign-top"><p class="tableblock">Functional</p></td>402 <td class="tableblock halign-left valign-top"><p class="tableblock">Persistent (10 years)</p></td>403 <td class="tableblock halign-left valign-top"><p class="tableblock">WeArePlanet</p></td>404 <td class="tableblock halign-left valign-top"><p class="tableblock">UI-version toggle for the WeArePlanet merchant portal (old vs. new UI). Set automatically on every login based on the user’s stored preference, and can be toggled by the user. HttpOnly, Secure on HTTPS.</p></td>405 </tr>406 399 </tbody> 407 400 </table> </div> -
weareplanet/trunk/includes/admin/class-wc-weareplanet-admin-refund.php
r3433358 r3740659 146 146 * Executes refund. 147 147 * 148 * @param WC_Order $order wc_order.148 * @param WC_Order $order wc_order. 149 149 * @param WC_Order_Refund $refund refund. 150 150 * @return void … … 279 279 * Creates a new refund job for the given order and refund. 280 280 * 281 * @param WC_Order $order wc_order.282 * @param WC_Order_Refund $refund refund.281 * @param WC_Order $order wc_order. 282 * @param WC_Order_Refund $refund refund. 283 283 * @param \WeArePlanet\Sdk\Model\RefundCreate $refund_create refund_create. 284 284 * @return WC_WeArePlanet_Entity_Refund_Job -
weareplanet/trunk/includes/admin/class-wc-weareplanet-admin-settings-page.php
r3676036 r3740659 109 109 */ 110 110 protected function get_settings_for_weareplanet_order_statuses_section() { 111 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $hide_save_button is a woocommerce core global used to control settings page ui, therefore we don't rename it 111 112 global $current_section, $hide_save_button; 112 113 $hide_save_button = true; 114 // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound 113 115 return $this->get_order_statuses(); 114 116 } … … 206 208 array( 207 209 'links' => array( 208 'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4. 8/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ),210 'https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-weareplanet' ), 209 211 'https://www.weareplanet.com/contact/sales' => esc_html__( 'Sign Up', 'woo-weareplanet' ), 210 212 ), … … 268 270 ), 269 271 270 array(271 'title'=> esc_html__( 'Disable Pending Email', 'woo-weareplanet' ),272 'desc'=> esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ),273 'id'=> WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL,274 'type'=> 'checkbox',275 'default' => 'no',276 'css'=> 'min-width:300px;',277 ),272 array( 273 'title' => esc_html__( 'Disable Pending Email', 'woo-weareplanet' ), 274 'desc' => esc_html__( 'Enable this setting to prevent WooCommerce from sending "pending payment" emails for WeArePlanet payment methods.', 'woo-weareplanet' ), 275 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 276 'type' => 'checkbox', 277 'default' => 'no', 278 'css' => 'min-width:300px;', 279 ), 278 280 279 281 array( … … 339 341 'desc_tip' => wp_kses_post( 340 342 __( 341 'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.',342 'woo-weareplanet'343 'The Integration Options setting determines how the payment form is displayed during the WooCommerce checkout process.<br><br><strong>IFrame</strong>: Embeds the payment form directly within the WooCommerce checkout page for a seamless experience.<br><br><strong>Lightbox</strong>: Opens a secure popup window for customers to complete their payment without leaving the checkout page.<br><br><strong>Payment Page</strong>: Redirects customers to a dedicated payment page hosted by the payment provider.', 344 'woo-weareplanet' 343 345 ) 344 346 ), … … 365 367 ), 366 368 367 array(368 'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ),369 'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ),370 'desc_tip' => esc_html__(371 "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.",372 'woo-weareplanet'373 ),374 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY,375 'type' => 'checkbox',376 'default' => 'yes',377 'css' => 'min-width:300px;',378 ),369 array( 370 'title' => esc_html__( 'Enforce Consistency', 'woo-weareplanet' ), 371 'desc' => esc_html__( 'Enable this setting to require that the sum of all line items matches the order total value.', 'woo-weareplanet' ), 372 'desc_tip' => esc_html__( 373 "WooCommerce calculates taxes at the line-item level, which may result in minor discrepancies (typically a few cents) between the order's total tax and the displayed price. This occurs due to rounding differences during individual line-item calculations.\n\nIf the \"Enforce consistency\" setting is enabled, the portal will automatically reject orders with such discrepancies. To avoid payment processing issues, we recommend disabling this setting unless strict tax total validation is required.", 374 'woo-weareplanet' 375 ), 376 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY, 377 'type' => 'checkbox', 378 'default' => 'yes', 379 'css' => 'min-width:300px;', 380 ), 379 381 380 382 array( … … 392 394 'title' => esc_html__( 'Order Reference Type', 'woo-weareplanet' ), 393 395 'desc_tip' => esc_html__( 394 'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.',395 'woo-weareplanet'396 'Choose how orders are uniquely identified when sent to the portal. This reference ensures orders can be tracked and reconciled between systems. We recommend to use Order ID unless your workflow requires custom identifiers.', 397 'woo-weareplanet' 396 398 ), 397 399 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ORDER_REFERENCE, … … 440 442 */ 441 443 public function get_order_status_settings() { 442 $settings = [];444 $settings = array(); 443 445 $is_custom_status_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled(); 444 446 … … 454 456 'desc' => esc_html__( 'If enabled, custom statuses (such as Manual Decision) will be used instead of the default WooCommerce statuses.', 'woo-weareplanet' ), 455 457 'id' => WooCommerce_WeArePlanet::WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING, 456 'type' => 'checkbox',458 'type' => 'checkbox', 457 459 'default' => 'no', 458 'css' => 'min-width:300px;',460 'css' => 'min-width:300px;', 459 461 ); 460 462 … … 475 477 <span class="weareplanet-status-mapping-col-left">%s</span> 476 478 <span class="weareplanet-status-mapping-col-right">%s</span> 477 </div>' 478 , 479 </div>', 479 480 esc_html__( 'WeArePlanet payment status', 'woo-weareplanet' ), 480 481 esc_html__( 'WooCommerce Order Status', 'woo-weareplanet' ) … … 519 520 ); 520 521 521 522 522 return apply_filters( 'weareplanet_custom_order_statuses_settings', $settings ); 523 523 } … … 592 592 'underscore', 593 593 'backbone', 594 'wc-backbone-modal' 594 'wc-backbone-modal', 595 595 ), 596 596 $version, -
weareplanet/trunk/includes/admin/class-wc-weareplanet-admin-transaction.php
r3463230 r3740659 45 45 * @see: https://woo.com/document/high-performance-order-storage/#section-8 46 46 * @see: https://developer.wordpress.org/reference/hooks/add_meta_boxes/ 47 * @param string $post_type The type of post where the meta box should be added.47 * @param string $post_type The type of post where the meta box should be added. 48 48 * @param WP_Post|WC_Order|null $post_or_order_object The post or order object. 49 49 */ 50 public static function add_meta_box( $post_type = "", $post_or_order_object = null ) {50 public static function add_meta_box( $post_type = '', $post_or_order_object = null ) { 51 51 // WooCommerce is moving the Order information from Post to Order class. For now, we need to support both ways. 52 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order ) ) {52 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof \Automattic\WooCommerce\Admin\Overrides\Order ) ) { 53 53 if ( empty( $post_or_order_object ) || ! ( $post_or_order_object instanceof WP_Post ) || empty( $post_or_order_object->ID ) || 'shop_order' != $post_or_order_object->post_type ) { 54 54 return; -
weareplanet/trunk/includes/admin/class-wc-weareplanet-admin.php
r3463230 r3740659 245 245 * Remove unwanted order actions 246 246 * 247 * @param array $actions actions.247 * @param array $actions actions. 248 248 * @param WC_Order $order order. 249 249 * @return array … … 389 389 */ 390 390 public function display_attribute_options_edit() { 391 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- read only display function. $_GET['edit'] is a woocommerce admin url param. Nonce is verified in the save handler. 391 392 if ( ! isset( $_GET['edit'] ) ) { 392 393 return; … … 394 395 $edit = absint( $_GET['edit'] ); 395 396 } 397 // phpcs:enable WordPress.Security.NonceVerification.Recommended 396 398 $checked = false; 397 399 $attribute_options = WC_WeArePlanet_Entity_Attribute_Options::load_by_attribute_id( $edit ); … … 407 409 </th> 408 410 <td> 409 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>411 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?> 410 412 <input 411 413 name="weareplanet_attribute_option_send" … … 429 431 <div class="form-field"> 430 432 <label for="weareplanet_attribute_option_send"> 431 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?>433 <?php wp_nonce_field( 'weareplanet_attribute_option_send', 'weareplanet_attribute_option_send_nonce' ); ?> 432 434 <input name="weareplanet_attribute_option_send" id="weareplanet_attribute_option_send" type="checkbox" value="1"> 433 435 <?php esc_html_e( 'Send attribute to WeArePlanet', 'woo-weareplanet' ); ?> -
weareplanet/trunk/includes/class-wc-weareplanet-blocks-support.php
r3676036 r3740659 1 1 <?php 2 3 2 /** 4 3 * Plugin Name: WeArePlanet … … 58 57 public function get_payment_method_script_handles() { 59 58 $dependencies = array(); 60 $version = '3.4. 8';59 $version = '3.4.9'; 61 60 62 61 wp_register_script( … … 107 106 $update_transaction = isset( $_POST['updateTransaction'] ) ? (bool) sanitize_key( wp_unslash( $_POST['updateTransaction'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing 108 107 $enqueue_portal_scripts = isset( $_POST['enqueuePortalScripts'] ) ? (bool) sanitize_key( wp_unslash( $_POST['enqueuePortalScripts'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing 109 108 110 109 if ( true === $update_transaction ) { 111 110 $transaction_service = WC_WeArePlanet_Service_Transaction::instance(); … … 122 121 123 122 $payment_plugin = array_filter( 124 $payment_gateways,125 fn( $key ) => str_contains( $key, 'weareplanet_' ),126 ARRAY_FILTER_USE_KEY123 $payment_gateways, 124 fn( $key ) => str_contains( $key, 'weareplanet_' ), 125 ARRAY_FILTER_USE_KEY 127 126 ); 128 127 129 128 $payments_list = 130 array_map(131 function ( $payment_gateway ) use ( $available_payment_methods ) {132 $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription();133 $cartTotal = (WC()->cart && WC()->cart->total) ?? 0;134 135 $isPaymentMethodVisibleOnCheckout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && $cartTotal == 0;136 $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID137 ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE138 : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION );139 140 if ( !$isPaymentMethodVisibleOnCheckout ) {141 $isPaymentMethodVisibleOnCheckout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cartTotal > 0 || $has_subscription );142 }143 144 return array(145 'name' => $payment_gateway->id,146 'label' => $payment_gateway->get_title(),147 'ariaLabel' => $payment_gateway->get_title(),148 'description' => $payment_gateway->get_description(),149 'configuration_id' => $payment_gateway->get_payment_configuration_id(),150 'integration_mode' => $integration_mode,151 'supports' => $payment_gateway->supports,152 'icon' => $payment_gateway->get_icon(),153 'isActive' => $isPaymentMethodVisibleOnCheckout154 );155 },156 $payment_plugin157 );129 array_map( 130 function ( $payment_gateway ) use ( $available_payment_methods ) { 131 $has_subscription = WC_WeArePlanet_Zero_Gateway::cart_has_subscription(); 132 $cart_total = ( WC()->cart && WC()->cart->total ) ?? 0; 133 134 $is_payment_method_visible_on_checkout = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID && 0 === $cart_total; 135 $integration_mode = $payment_gateway->get_payment_configuration_id() === WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID 136 ? WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE 137 : get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ); 138 139 if ( ! $is_payment_method_visible_on_checkout ) { 140 $is_payment_method_visible_on_checkout = in_array( $payment_gateway->get_payment_configuration_id(), $available_payment_methods, true ) && ( $cart_total > 0 || $has_subscription ); 141 } 142 143 return array( 144 'name' => $payment_gateway->id, 145 'label' => $payment_gateway->get_title(), 146 'ariaLabel' => $payment_gateway->get_title(), 147 'description' => $payment_gateway->get_description(), 148 'configuration_id' => $payment_gateway->get_payment_configuration_id(), 149 'integration_mode' => $integration_mode, 150 'supports' => $payment_gateway->supports, 151 'icon' => $payment_gateway->get_icon(), 152 'isActive' => $is_payment_method_visible_on_checkout, 153 ); 154 }, 155 $payment_plugin 156 ); 158 157 159 158 return array_values( $payments_list ); 160 } catch ( \Exception $e) {161 return [];159 } catch ( \Exception $e ) { 160 return array(); 162 161 } 163 162 } … … 213 212 */ 214 213 public static function enqueue_portal_scripts() { 215 if ( is_order_received_page() ) return; 214 if ( is_order_received_page() ) { 215 return; 216 } 216 217 217 218 try { … … 219 220 $transaction_service = WC_WeArePlanet_Service_Transaction::instance(); 220 221 $transaction = $transaction_service->get_transaction_from_session(); 221 switch ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) {222 switch ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) ) { 222 223 case WC_WeArePlanet_Integration::WEAREPLANET_IFRAME: 223 224 $js_url = $transaction_service->get_javascript_url_for_transaction( $transaction ); … … 281 282 [$gateway_result, $transaction] = $payment_method_object->process_payment_transaction( $context->order, $transaction_id, $space_id, true, $transaction_service ); 282 283 283 284 284 $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ); 285 285 $redirect_url = $gateway_result['redirect']; -
weareplanet/trunk/includes/class-wc-weareplanet-commands.php
r3378673 r3740659 19 19 if ( class_exists( 'WP_CLI' ) && ! class_exists( 'WC_WeArePlanet_Commands' ) ) { 20 20 21 /**22 * Class WC_WeArePlanet_Commands.23 * This class contains custom commands for WeArePlanet.24 *25 * @class WC_WeArePlanet_Commands26 */27 class WC_WeArePlanet_Commands {21 /** 22 * Class WC_WeArePlanet_Commands. 23 * This class contains custom commands for WeArePlanet. 24 * 25 * @class WC_WeArePlanet_Commands 26 */ 27 class WC_WeArePlanet_Commands { 28 28 29 /**30 * Register commands.31 */32 public static function init() {33 WP_CLI::add_command(34 'weareplanet settings init',35 array(36 __CLASS__,37 'settings_init' 38 )39 );40 WP_CLI::add_command(41 'weareplanet webhooks install',42 array(43 __CLASS__,44 'webhooks_install' 45 )46 );47 WP_CLI::add_command(48 'weareplanet payment-methods sync',49 array(50 __CLASS__,51 'payment_methods_sync' 52 )53 );54 }29 /** 30 * Register commands. 31 */ 32 public static function init() { 33 WP_CLI::add_command( 34 'weareplanet settings init', 35 array( 36 __CLASS__, 37 'settings_init', 38 ) 39 ); 40 WP_CLI::add_command( 41 'weareplanet webhooks install', 42 array( 43 __CLASS__, 44 'webhooks_install', 45 ) 46 ); 47 WP_CLI::add_command( 48 'weareplanet payment-methods sync', 49 array( 50 __CLASS__, 51 'payment_methods_sync', 52 ) 53 ); 54 } 55 55 56 /**57 * Initialize WeArePlanet settings.58 * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet.59 *60 * ## EXAMPLE61 *62 *$ wp weareplanet settings init63 *64 * @param array $args WP-CLI positional arguments.65 * @param array $assoc_args WP-CLI associative arguments.66 */67 public static function settings_init( $args, $assoc_args ) {68 try {69 $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings();70 foreach ( $default_settings as $setting => $value ) {71 $current_setting = get_option( $setting, false );72 if ( $current_setting === false) {73 update_option( $setting, $value );74 }75 }76 WP_CLI::success( "Settings initialized.");77 } catch ( \Exception $e ) {78 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );79 WP_CLI::error( "Failed to initialize settings: ". $e->getMessage() );80 }81 }56 /** 57 * Initialize WeArePlanet settings. 58 * It doesn't reset settings to default, it sets default settings if they haven't been initialized yet. 59 * 60 * ## EXAMPLE 61 * 62 * $ wp weareplanet settings init 63 * 64 * @param array $args WP-CLI positional arguments. 65 * @param array $assoc_args WP-CLI associative arguments. 66 */ 67 public static function settings_init( $args, $assoc_args ) { 68 try { 69 $default_settings = WC_WeArePlanet_Helper::instance()->get_default_settings(); 70 foreach ( $default_settings as $setting => $value ) { 71 $current_setting = get_option( $setting, false ); 72 if ( false === $current_setting ) { 73 update_option( $setting, $value ); 74 } 75 } 76 WP_CLI::success( 'Settings initialized.' ); 77 } catch ( \Exception $e ) { 78 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR ); 79 WP_CLI::error( 'Failed to initialize settings: ' . $e->getMessage() ); 80 } 81 } 82 82 83 /**84 * Create webhook URL and webhook listeners in the portal for WeArePlanet.85 *86 * ## EXAMPLE87 *88 *$ wp weareplanet webhooks install89 *90 * @param array $args WP-CLI positional arguments.91 * @param array $assoc_args WP-CLI associative arguments.92 */93 public static function webhooks_install( $args, $assoc_args ) {94 try {95 WC_WeArePlanet_Helper::instance()->reset_api_client();96 WC_WeArePlanet_Service_Webhook::instance()->install();97 WP_CLI::success( "Webhooks installed.");98 } catch ( \Exception $e ) {99 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );100 WP_CLI::error( "Failed to install webhooks: ". $e->getMessage() );101 }102 }83 /** 84 * Create webhook URL and webhook listeners in the portal for WeArePlanet. 85 * 86 * ## EXAMPLE 87 * 88 * $ wp weareplanet webhooks install 89 * 90 * @param array $args WP-CLI positional arguments. 91 * @param array $assoc_args WP-CLI associative arguments. 92 */ 93 public static function webhooks_install( $args, $assoc_args ) { 94 try { 95 WC_WeArePlanet_Helper::instance()->reset_api_client(); 96 WC_WeArePlanet_Service_Webhook::instance()->install(); 97 WP_CLI::success( 'Webhooks installed.' ); 98 } catch ( \Exception $e ) { 99 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR ); 100 WP_CLI::error( 'Failed to install webhooks: ' . $e->getMessage() ); 101 } 102 } 103 103 104 /**105 * Synchronizes payment methods in the WeArePlanet from the portal.106 *107 * ## EXAMPLE108 *109 *$ wp weareplanet payment-methods sync110 *111 * @param array $args WP-CLI positional arguments.112 * @param array $assoc_args WP-CLI associative arguments.113 */114 public static function payment_methods_sync( $args, $assoc_args ) {115 try {116 WC_WeArePlanet_Helper::instance()->reset_api_client();117 WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize();118 WC_WeArePlanet_Helper::instance()->delete_provider_transients();119 WP_CLI::success( "Payment methods synchronized.");120 } catch ( \Exception $e ) {121 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR );122 WP_CLI::error( "Failed to synchronize payment methods: ". $e->getMessage() );123 }124 }125 }104 /** 105 * Synchronizes payment methods in the WeArePlanet from the portal. 106 * 107 * ## EXAMPLE 108 * 109 * $ wp weareplanet payment-methods sync 110 * 111 * @param array $args WP-CLI positional arguments. 112 * @param array $assoc_args WP-CLI associative arguments. 113 */ 114 public static function payment_methods_sync( $args, $assoc_args ) { 115 try { 116 WC_WeArePlanet_Helper::instance()->reset_api_client(); 117 WC_WeArePlanet_Service_Method_Configuration::instance()->synchronize(); 118 WC_WeArePlanet_Helper::instance()->delete_provider_transients(); 119 WP_CLI::success( 'Payment methods synchronized.' ); 120 } catch ( \Exception $e ) { 121 WooCommerce_WeArePlanet::instance()->log( $e->getMessage(), WC_Log_Levels::ERROR ); 122 WP_CLI::error( 'Failed to synchronize payment methods: ' . $e->getMessage() ); 123 } 124 } 125 } 126 126 } 127 127 -
weareplanet/trunk/includes/class-wc-weareplanet-customer-document.php
r3288388 r3740659 109 109 array( 110 110 'weareplanet_action' => 'download_packing', 111 'post' => $order_id,112 'nonce' => wp_create_nonce( 'download_packing' ),111 'post' => $order_id, 112 'nonce' => wp_create_nonce( 'download_packing' ), 113 113 ) 114 114 ) … … 130 130 */ 131 131 private static function is_pdf_request() { 132 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- nonce is verified in download_document() 132 133 return ( isset( $_GET['post'] ) && isset( $_GET['weareplanet_action'] ) && isset( $_GET['nonce'] ) ); 134 // phpcs:enable WordPress.Security.NonceVerification.Recommended 133 135 } 134 136 -
weareplanet/trunk/includes/class-wc-weareplanet-email.php
r3378673 r3740659 28 28 /** 29 29 * Allow on hold emails being sent when germanized plugin is installed. 30 * 31 * @var bool 30 32 */ 31 33 private static $allow_on_hold_emails = false; … … 39 41 array( 40 42 __CLASS__, 41 'send_on_hold_email_when_authorized'43 'send_on_hold_email_when_authorized', 42 44 ), 43 45 10, … … 156 158 add_filter( 'woocommerce_email_actions', array( __CLASS__, 'add_email_actions' ), 10, 1 ); 157 159 add_filter( 'woocommerce_email_classes', array( __CLASS__, 'add_email_classes' ), 100, 1 ); 158 add_filter( 159 'woocommerce_email_enabled_customer_on_hold_order', 160 array( __CLASS__, 'disable_pending_payment_email' ), 161 10, 162 2 163 ); 164 } 165 166 /** 167 * @param $order_id 160 add_filter( 161 'woocommerce_email_enabled_customer_on_hold_order', 162 array( __CLASS__, 'disable_pending_payment_email' ), 163 10, 164 2 165 ); 166 } 167 168 /** 169 * Trigger the on-hold email when an order is authorized. 170 * 171 * @param int $order_id order id. 168 172 * @return void 169 173 */ … … 336 340 public static function add_email_actions( $actions ) { 337 341 338 $to_add = array(339 'woocommerce_order_status_wearep-redirected_to_processing',340 'woocommerce_order_status_wearep-redirected_to_completed',341 'woocommerce_order_status_wearep-redirected_to_on-hold',342 'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting',343 'woocommerce_order_status_wearep-redirected_to_weareplanet-manual',344 'woocommerce_order_status_wearep-manual_to_cancelled',345 'woocommerce_order_status_wearep-waiting_to_cancelled',346 'woocommerce_order_status_wearep-manual_to_processing',347 'woocommerce_order_status_wearep-waiting_to_processing',348 );349 350 $authorized_status = self::get_transaction_mapped_status( 'authorized' );351 $fulfill_status = self::get_transaction_mapped_status( 'fulfill' );352 353 if ( $authorized_status && $fulfill_status ) {354 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status );355 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status );356 }342 $to_add = array( 343 'woocommerce_order_status_wearep-redirected_to_processing', 344 'woocommerce_order_status_wearep-redirected_to_completed', 345 'woocommerce_order_status_wearep-redirected_to_on-hold', 346 'woocommerce_order_status_wearep-redirected_to_weareplanet-waiting', 347 'woocommerce_order_status_wearep-redirected_to_weareplanet-manual', 348 'woocommerce_order_status_wearep-manual_to_cancelled', 349 'woocommerce_order_status_wearep-waiting_to_cancelled', 350 'woocommerce_order_status_wearep-manual_to_processing', 351 'woocommerce_order_status_wearep-waiting_to_processing', 352 ); 353 354 $authorized_status = self::get_transaction_mapped_status( 'authorized' ); 355 $fulfill_status = self::get_transaction_mapped_status( 'fulfill' ); 356 357 if ( $authorized_status && $fulfill_status ) { 358 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status ); 359 self::add_unique_action( $to_add, 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status ); 360 } 357 361 358 362 if ( class_exists( 'woocommerce_wpml' ) ) { … … 537 541 break; 538 542 539 case 'WC_Email_Customer_On_Hold_Order':540 add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 );541 if ( $authorized_status && $fulfill_status ) {542 add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 );543 }544 break;545 546 case 'WC_Email_Customer_Processing_Order':547 add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );548 add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );549 add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 );550 if ( $authorized_status && $fulfill_status ) {551 add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 );552 }553 break;543 case 'WC_Email_Customer_On_Hold_Order': 544 add_action( 'woocommerce_order_status_wearep-redirected_to_on-hold_notification', array( $email_object, 'trigger' ), 10, 2 ); 545 if ( $authorized_status && $fulfill_status ) { 546 add_action( 'woocommerce_order_status_' . $fulfill_status . '_to_' . $authorized_status . '_notification', array( __CLASS__, 'maybe_send_on_hold_email_for_manual_status' ), 10, 2 ); 547 } 548 break; 549 550 case 'WC_Email_Customer_Processing_Order': 551 add_action( 'woocommerce_order_status_wearep-redirected_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 ); 552 add_action( 'woocommerce_order_status_wearep-manual_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 ); 553 add_action( 'woocommerce_order_status_wearep-waiting_to_processing_notification', array( $email_object, 'trigger' ), 10, 2 ); 554 if ( $authorized_status && $fulfill_status ) { 555 add_action( 'woocommerce_order_status_' . $authorized_status . '_to_' . $fulfill_status . '_notification', array( $email_object, 'trigger' ), 10, 2 ); 556 } 557 break; 554 558 555 559 case 'WC_Email_Customer_Completed_Order': … … 575 579 * @return bool 576 580 */ 577 public static function gzd_block_send_instant_order_confirmation ( $email_sent, $order ) {581 public static function gzd_block_send_instant_order_confirmation( $email_sent, $order ) { 578 582 if ( ! ( $order instanceof WC_Order ) ) { 579 583 return $email_sent; … … 623 627 624 628 /** 625 * @param WC_Order $order 629 * Check if the order is an on-hold order and if it is authorized. 630 * 631 * @param WC_Order $order WooCommerce order object. 626 632 * @return bool 627 633 */ … … 639 645 } 640 646 641 /**642 * This prevents WooCommerce from sending the "customer on hold" email643 * when the order was placed using any WeArePlanet payment method644 * and the merchant has disabled this behavior in the plugin settings.645 *646 * @param bool $enabled Whether the email is enabled.647 * @param WC_Order $orderWooCommerce order object.648 *649 * @return bool650 */651 public static function disable_pending_payment_email( $enabled, $order ) {652 if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) {653 return $enabled;654 }655 656 $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' );657 $gateway = wc_get_payment_gateway_by_order( $order );658 659 if ( $gateway instanceof WC_WeArePlanet_Gateway && $disable === 'yes') {660 return false;661 }662 663 return $enabled;664 }647 /** 648 * This prevents WooCommerce from sending the "customer on hold" email 649 * when the order was placed using any WeArePlanet payment method 650 * and the merchant has disabled this behavior in the plugin settings. 651 * 652 * @param bool $enabled Whether the email is enabled. 653 * @param WC_Order $order WooCommerce order object. 654 * 655 * @return bool 656 */ 657 public static function disable_pending_payment_email( $enabled, $order ) { 658 if ( ! $enabled || ! is_a( $order, 'WC_Order' ) ) { 659 return $enabled; 660 } 661 662 $disable = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_DISABLE_PENDING_EMAIL, 'no' ); 663 $gateway = wc_get_payment_gateway_by_order( $order ); 664 665 if ( $gateway instanceof WC_WeArePlanet_Gateway && 'yes' === $disable ) { 666 return false; 667 } 668 669 return $enabled; 670 } 665 671 } 666 672 -
weareplanet/trunk/includes/class-wc-weareplanet-gateway.php
r3550708 r3740659 278 278 $field_key = $this->get_field_key( $key ); 279 279 $defaults = array( 280 'title' => '',281 'class' => '',282 'css' => '',283 'placeholder' => '',284 'desc_tip' => true,285 'description' => '',280 'title' => '', 281 'class' => '', 282 'css' => '', 283 'placeholder' => '', 284 'desc_tip' => true, 285 'description' => '', 286 286 'custom_attributes' => array(), 287 287 ); … … 292 292 <th scope="row" class="titledesc"> 293 293 <label for="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $data['title'] ); ?></label> 294 <?php echo $this->get_tooltip_html( $data); ?>294 <?php echo wp_kses_post( $this->get_tooltip_html( $data ) ); ?> 295 295 </th> 296 296 <td class="forminp"> … … 303 303 id="<?php echo esc_attr( $field_key ); ?>" 304 304 style="<?php echo esc_attr( $data['css'] ); ?>" 305 <?php echo $this->get_custom_attribute_html( $data); ?>305 <?php echo wp_kses_post( $this->get_custom_attribute_html( $data ) ); ?> 306 306 > 307 307 <?php echo wp_kses_post( $data['value'] ); ?> … … 331 331 static $checking = false; 332 332 if ( $checking ) { 333 return false; // prevent reentry/loop 333 return false; // prevent reentry/loop. 334 334 } 335 335 $checking = true; 336 336 337 337 try { 338 // Respect parent availability 338 // Respect parent availability. 339 339 if ( ! parent::is_available() ) { 340 340 return false; 341 341 } 342 342 343 // Prevent conflict with tax rounding 343 // Prevent conflict with tax rounding. 344 344 if ( wc_tax_enabled() && 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) { 345 345 if ( 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_ENFORCE_CONSISTENCY ) ) { … … 350 350 } 351 351 352 // Use session cache if available 352 // Use session cache if available. 353 353 $gateway_available = WC()->session && $this->has_session() 354 354 ? WC()->session->get( 'weareplanet_payment_gateways' ) … … 359 359 } 360 360 361 // Allow admin and non-checkout pages to pass 361 // Allow admin and non-checkout pages to pass. 362 362 if ( apply_filters( 363 363 'weareplanet_is_method_available', … … 368 368 } 369 369 370 // Handle "order received" page logic 370 // Handle "order received" page logic. 371 371 global $wp; 372 372 if ( is_checkout() && isset( $wp->query_vars['order-received'] ) ) { … … 374 374 } 375 375 376 // Handle "order pay" endpoint 376 // Handle "order pay" endpoint. 377 377 if ( apply_filters( 'wc_weareplanet_is_order_pay_endpoint', is_checkout_pay_page() ) ) { 378 378 $order = WC_Order_Factory::get_order( $wp->query_vars['order-pay'] ?? 0 ); … … 385 385 } 386 386 387 // Check if this gateway is among the possible ones 387 // Check if this gateway is among the possible ones. 388 388 $possible = false; 389 389 foreach ( $possible_methods as $method_id ) { … … 398 398 } 399 399 400 // Cache success in session 400 // Cache success in session. 401 401 if ( WC()->session && $this->has_session() ) { 402 402 $gateway_available[ $this->pln_payment_method_configuration_id ] = true; … … 538 538 } 539 539 540 /** 541 * Enqueue checkout scripts. 542 */ 540 543 public function enqueue_checkout_scripts() { 541 544 if ( ! is_checkout() && ! is_checkout_pay_page() ) { … … 565 568 } 566 569 567 if (get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE) {568 return false;570 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ) == WC_WeArePlanet_Integration::WEAREPLANET_PAYMENTPAGE ) { 571 return false; 569 572 } 570 573 571 574 wp_enqueue_script( 572 'weareplanet-remote-checkout-js',573 $ajax_url,574 array(575 'jquery',576 ),577 1,578 true575 'weareplanet-remote-checkout-js', 576 $ajax_url, 577 array( 578 'jquery', 579 ), 580 1, 581 true 579 582 ); 580 583 wp_enqueue_script( 581 'weareplanet-checkout-js',582 WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js',583 array(584 'jquery',585 'jquery-blockui',586 'weareplanet-remote-checkout-js',587 ),588 1,589 true584 'weareplanet-checkout-js', 585 WooCommerce_WeArePlanet::instance()->plugin_url() . '/assets/js/frontend/checkout.js', 586 array( 587 'jquery', 588 'jquery-blockui', 589 'weareplanet-remote-checkout-js', 590 ), 591 1, 592 true 590 593 ); 591 594 global $wp_version; 592 595 $localize = array( 593 'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ),594 'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ),595 'versions' => array(596 'wordpress' => $wp_version,597 'woocommerce' => $woocommerce_data['Version'],598 'weareplanet' => WC_WEAREPLANET_VERSION,599 ),596 'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-weareplanet' ), 597 'integration' => get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ), 598 'versions' => array( 599 'wordpress' => $wp_version, 600 'woocommerce' => $woocommerce_data['Version'], 601 'weareplanet' => WC_WEAREPLANET_VERSION, 602 ), 600 603 ); 601 604 wp_localize_script( 'weareplanet-checkout-js', 'weareplanet_js_params', $localize ); … … 666 669 667 670 [ $result, $transaction ] = $this->process_payment_transaction( $order, $transaction_id, $space_id, $is_order_pay_endpoint, $transaction_service ); 668 669 671 670 672 $integration_mode = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_INTEGRATION ); … … 717 719 * in the order. It also sets up the redirect URL upon successful payment and returns the result and transaction. 718 720 * 719 * @param WC_Order $order The WooCommerce order object.720 * @param int $transaction_id The ID of the transaction.721 * @param int $space_id The space ID associated with the transaction.722 * @param bool $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint.721 * @param WC_Order $order The WooCommerce order object. 722 * @param int $transaction_id The ID of the transaction. 723 * @param int $space_id The space ID associated with the transaction. 724 * @param bool $is_order_pay_endpoint Flag to determine if the order is being paid for at the order-pay endpoint. 723 725 * @param WC_WeArePlanet_Service_Transaction $transaction_service The transaction service instance. 724 726 * @return array An array containing the result of the transaction and the transaction object. -
weareplanet/trunk/includes/class-wc-weareplanet-helper.php
r3676036 r3740659 76 76 * 77 77 * @param string $status_slug Order status slug, with or without the `wc-` prefix. 78 * @param bool $prefixed When true the returned status contains the `wc-` prefix.78 * @param bool $prefixed When true the returned status contains the `wc-` prefix. 79 79 * @return string 80 80 */ … … 121 121 122 122 /** 123 * Delete language transient. 124 * 125 * @return void 126 */ 127 public function delete_language_transient() { 128 delete_transient( 'wc_weareplanet_languages' ); 129 } 130 131 /** 123 132 * Get api client. 124 133 * … … 144 153 * Add headers to api client. 145 154 * 155 * @param \WeArePlanet\Sdk\ApiClient $api_client api client. 146 156 * @param array $additional_headers Additional headers. 147 157 * @return void 148 158 */ 149 public static function add_headers( &$api_client, array $additional_headers = []) {159 public static function add_headers( &$api_client, array $additional_headers = array() ) { 150 160 $default_header_data = self::get_default_header_data(); 151 161 $default_header_data = array_merge( $default_header_data, $additional_headers ); … … 269 279 $name = $line_item->getName(); 270 280 271 // Handle coupons normally 281 // Handle coupons normally. 272 282 if ( $exclude_discounts && \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type 273 283 && strpos( $name, WC_WeArePlanet_Packages_Coupon_Discount::WEAREPLANET_COUPON ) !== false … … 275 285 // Convert negative values to positive in order to be able to subtract it. 276 286 $sum -= abs( $line_item->getAmountIncludingTax() ); 277 } 278 // Handle gift cards separately (already negative, do not abs()) 279 elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type 280 && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD) !== false 287 } elseif ( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT === $type 288 && stripos( $name, WC_WeArePlanet_Packages_Gift_Card::WEAREPLANET_GIFT_CARD ) !== false 281 289 ) { 290 // Handle gift cards separately (already negative, do not abs()). 282 291 $sum += $line_item->getAmountIncludingTax(); 283 } 284 else { 292 } else { 285 293 $sum += $line_item->getAmountIncludingTax(); 286 294 } … … 295 303 * @param mixed $expected_sum expected sum. 296 304 * @param mixed $currency currency. 305 * @param bool $is_recurrent is recurrent. 297 306 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] 298 307 * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount. … … 301 310 // Check if coupon is applied to order. Session cart might be empty during webhook processing. 302 311 $has_coupons = apply_filters( 'wc_weareplanet_packages_coupon_line_items_have_coupon_discounts', $line_items, $currency ); 303 // ensure that the effective sum coincides with the total discounted by the coupons.312 // ensure that the effective sum coincides with the total discounted by the coupons. 304 313 $effective_sum = $this->round_amount( $this->get_total_amount_including_tax( $line_items, $has_coupons ), $currency ); 305 314 $rounded_expected_sum = $this->round_amount( $expected_sum, $currency ); … … 441 450 $locked_at = gmdate( 'Y-m-d H:i:s' ); 442 451 $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info'; 443 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.452 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 444 453 $wpdb->query( 445 454 $wpdb->prepare( … … 450 459 ); 451 460 452 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .453 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.461 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 462 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 454 463 $wpdb->query( 455 464 $wpdb->prepare( … … 462 471 ) 463 472 ); 464 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .473 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 465 474 } 466 475 … … 634 643 635 644 $shop_version = str_replace( 'v', '', $version ); 636 $plugin_version = '3.4. 8';645 $plugin_version = '3.4.9'; 637 646 list ($major_version, $minor_version) = explode( '.', $shop_version, 3 ); 638 647 return array( … … 645 654 646 655 /** 647 * Get WooCommerce order statuses in JSON format.648 *649 * This method retrieves the WooCommerce order statuses, applies any filters,650 * and returns them as an array with structured data.651 *652 * @return array[] An array of WooCommerce order statuses, where each status is represented653 * as an associative array containing:654 * - 'key' (string) : The order status key.655 * - 'label' (string) : The human-readable label for the status.656 * - 'type' (string) : The type of status ('core' if it starts with 'wc-', otherwise 'custom').657 */656 * Get WooCommerce order statuses in JSON format. 657 * 658 * This method retrieves the WooCommerce order statuses, applies any filters, 659 * and returns them as an array with structured data. 660 * 661 * @return array[] An array of WooCommerce order statuses, where each status is represented 662 * as an associative array containing: 663 * - 'key' (string) : The order status key. 664 * - 'label' (string) : The human-readable label for the status. 665 * - 'type' (string) : The type of status ('core' if it starts with 'wc-', otherwise 'custom'). 666 */ 658 667 public function get_woocommerce_order_statuses_json() { 659 668 $woocommerce_statuses = apply_filters( 'weareplanet_woocommerce_statuses', array() ); … … 667 676 'wc-failed', 668 677 'wc-trash', 669 'wc-checkout-draft' 678 'wc-checkout-draft', 670 679 ); 671 680 if ( self::is_custom_status_mapping_enabled() ) { … … 675 684 'wc-wearep-manual', 676 685 'wc-wearep-redirected', 677 'wc-wearep-waiting' 686 'wc-wearep-waiting', 678 687 ) 679 688 ); 680 689 } 681 690 682 return array_map( function( $key, $value ) use ( $excluded_statuses ) { 691 return array_map( 692 function ( $key, $value ) use ( $excluded_statuses ) { 683 693 return array( 684 694 'key' => $key, … … 693 703 694 704 /** 695 * @param $order 705 * Set virtual zero total orders to complete. 706 * 707 * @param WC_Order $order WC_Order The WooCommerce order object. 696 708 * @return void 697 709 */ … … 704 716 705 717 /** 706 * @param $order 718 * Check if the order is virtual (contains only virtual products). 719 * 720 * @param WC_Order $order WC_Order The WooCommerce order object. 707 721 * @return bool 708 722 */ … … 728 742 * Update WooCommerce order status to "Pre-Order" if any product is out of stock or marked as pre-order. 729 743 * 730 * @param WC_Order $order WooCommerce order object.744 * @param WC_Order $order WooCommerce order object. 731 745 */ 732 746 public static function update_order_status_for_preorder_if_needed( $order ) { … … 757 771 758 772 if ( $is_preorder_wc || $is_preorder_yith ) { 759 // Check if order is marked as pre-ordered 773 // Check if order is marked as pre-ordered. 760 774 if ( 'yes' !== $order->get_meta( '_order_has_preorder' ) ) { 761 775 return; 762 776 } 763 777 764 // Check if Yith Pre-Order plugin setting 778 // Check if Yith Pre-Order plugin setting. 765 779 if ( 'default' === get_option( 'ywpo_order_status', 'default' ) ) { 766 780 return; … … 770 784 } 771 785 772 // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available 786 // Check if product is not out of stock. Edge case: sometimes get_stock_quantity is not set, but then items are available. 773 787 if ( ( $product->get_stock_quantity() ?? 1 ) < 1 ) { 774 788 $is_out_of_stock = true; … … 777 791 } 778 792 779 if ( ! $is_preorder && !$is_out_of_stock ) {793 if ( ! $is_preorder && ! $is_out_of_stock ) { 780 794 return; 781 795 } … … 796 810 797 811 $order->update_status( 798 $preorder_status_slug,799 __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' )812 $preorder_status_slug, 813 __( 'Product is on pre-order. Status set automatically.', 'woo-weareplanet' ) 800 814 ); 801 815 802 816 $order->add_order_note( 803 __( 'Order status automatically set to pre-order.', 'woo-weareplanet' )817 __( 'Order status automatically set to pre-order.', 'woo-weareplanet' ) 804 818 ); 805 819 } … … 823 837 return $settings; 824 838 } 825 826 839 } -
weareplanet/trunk/includes/class-wc-weareplanet-migration.php
r3676036 r3740659 56 56 '1.0.9' => 'update_1_0_9_restore_default_status_mappings', 57 57 '1.0.10' => 'update_1_0_10_remove_previous_min_version', 58 '1.0.11' => 'update_1_0_11_enforce_signed_webhook_listeners', 59 '1.0.12' => 'update_1_0_12_clear_language_cache', 58 60 ); 59 61 … … 74 76 array( 75 77 __CLASS__, 76 'wp_initialize_site' 78 'wp_initialize_site', 77 79 ), 78 80 10, … … 180 182 * Create tables if new MU blog is created 181 183 * 182 * wp_initialize_site hook introduced since 5.1.0 184 * Function wp_initialize_site hook introduced since 5.1.0 185 * 183 186 * @link https://developer.wordpress.org/reference/hooks/wp_initialize_site/ 184 187 * 185 * @param WP_Site $site 186 * @param array $args188 * @param WP_Site $site site. 189 * @param array $args arguments. 187 190 * @return void 188 191 */ … … 190 193 if ( is_plugin_active_for_network( 'woo-weareplanet/weareplanet.php' ) ) { 191 194 $blog_id = $site->blog_id; 192 // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error 195 // Defensive check: blog_id should always be set, otherwise will be shown as weareplanet error. 193 196 if ( ! $blog_id ) { 194 197 $logger = wc_get_logger(); 195 $logger->error( 'Could not detect blog_id during wp_initialize_site.', [ 'source' => 'weareplanet' ]);198 $logger->error( 'Could not detect blog_id during wp_initialize_site.', array( 'source' => 'weareplanet' ) ); 196 199 return; 197 200 } … … 252 255 $current_version = get_option( self::WEAREPLANET_CK_DB_VERSION, 0 ); 253 256 $version_keys = array_keys( self::$db_migrations ); 254 if ( $current_version === 0 || version_compare( $current_version, '0', '>' ) && version_compare( $current_version, end( $version_keys ), '<' ) ) { 257 if ( version_compare( $current_version, end( $version_keys ), '<' ) 258 && ( 259 0 === $current_version 260 || version_compare( $current_version, '0', '>' ) 261 ) 262 ) { 255 263 // We migrate the Db for all blogs. 256 264 self::install_db( true ); … … 279 287 if ( WC_WEAREPLANET_PLUGIN_BASENAME === $file ) { 280 288 $row_meta = array( 281 'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4. 8/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>',289 'docs' => '<a href="https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-weareplanet' ) . '">' . esc_html__( 'Documentation', 'woo-weareplanet' ) . '</a>', 282 290 ); 283 291 … … 297 305 298 306 $table_method_config = $wpdb->prefix . 'weareplanet_method_config'; 299 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.307 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 300 308 $sql = "CREATE TABLE IF NOT EXISTS $table_method_config( 301 309 `id` int(10) unsigned NOT NULL AUTO_INCREMENT, … … 315 323 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; 316 324 // phpcs:enable 317 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery -- $sql is prepared.325 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter -- $sql is prepared. 318 326 $result = $wpdb->query( $sql ); 319 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery 327 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter 320 328 321 329 if ( false === $result ) { … … 325 333 $table_transaction_info = $wpdb->prefix . 'weareplanet_transaction_info'; 326 334 327 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.335 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 328 336 $result = $wpdb->query( 329 337 "CREATE TABLE IF NOT EXISTS $table_transaction_info( … … 350 358 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 351 359 ); 352 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .360 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter 353 361 354 362 if ( false === $result ) { … … 358 366 $table_token_info = $wpdb->prefix . 'weareplanet_token_info'; 359 367 360 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.368 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 361 369 $result = $wpdb->query( 362 370 "CREATE TABLE IF NOT EXISTS $table_token_info( … … 378 386 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 379 387 ); 380 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .388 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 381 389 382 390 if ( false === $result ) { … … 386 394 $table_completion_job = $wpdb->prefix . 'weareplanet_completion_job'; 387 395 388 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.396 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 389 397 $result = $wpdb->query( 390 398 "CREATE TABLE IF NOT EXISTS $table_completion_job( … … 406 414 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 407 415 ); 408 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .416 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 409 417 410 418 if ( false === $result ) { … … 414 422 $table_void_job = $wpdb->prefix . 'weareplanet_void_job'; 415 423 416 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.424 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 417 425 $result = $wpdb->query( 418 426 "CREATE TABLE IF NOT EXISTS $table_void_job( … … 432 440 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 433 441 ); 434 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .442 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 435 443 436 444 if ( false === $result ) { … … 440 448 $table_refund_job = $wpdb->prefix . 'weareplanet_refund_job'; 441 449 442 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.450 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 443 451 $result = $wpdb->query( 444 452 "CREATE TABLE IF NOT EXISTS $table_refund_job( … … 459 467 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 460 468 ); 461 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .469 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 462 470 463 471 if ( false === $result ) { … … 477 485 $table_method_config = $wpdb->prefix . 'weareplanet_method_config'; 478 486 479 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.487 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 480 488 $result = $wpdb->query( "ALTER TABLE $table_method_config CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" ); 481 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .482 483 if ( false === $result ) { 484 throw new Exception( esc_html( $wpdb->last_error ) ); 485 } 486 487 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.489 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 490 491 if ( false === $result ) { 492 throw new Exception( esc_html( $wpdb->last_error ) ); 493 } 494 495 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 488 496 $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `image` `image` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL" ); 489 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .497 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 490 498 491 499 if ( false === $result ) { … … 505 513 $table_token_info = $wpdb->prefix . 'weareplanet_token_info'; 506 514 507 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.515 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 508 516 $result = $wpdb->query( "ALTER TABLE $table_transaction_info CHANGE `order_id` `order_id` int(10) unsigned NULL DEFAULT NULL" ); 509 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .510 511 if ( false === $result ) { 512 throw new Exception( esc_html( $wpdb->last_error ) ); 513 } 514 515 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.517 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 518 519 if ( false === $result ) { 520 throw new Exception( esc_html( $wpdb->last_error ) ); 521 } 522 523 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 516 524 $result = $wpdb->query( 517 525 $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'order_mapping_id' ) 518 526 ); 519 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .527 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 520 528 521 529 if ( 0 === $result ) { 522 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.530 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 523 531 $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD `order_mapping_id` int(10) unsigned NULL AFTER order_id" ); 524 532 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery … … 529 537 } 530 538 531 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.539 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 532 540 $result = $wpdb->query( "ALTER TABLE $table_token_info CHANGE `customer_id` `customer_id` int(10) unsigned NULL DEFAULT NULL" ); 533 541 // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCachin,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery … … 552 560 553 561 if ( 0 === $result ) { 554 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.562 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 555 563 $result = $wpdb->query( "ALTER TABLE $table_method_config ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" ); 556 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .564 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 557 565 558 566 if ( false === $result ) { … … 561 569 } 562 570 563 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.571 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 564 572 $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'image_base' ) ); 565 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .573 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 566 574 567 575 if ( 0 === $result ) { 568 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.576 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 569 577 $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `image_base` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER image" ); 570 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .578 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 571 579 572 580 if ( false === $result ) { … … 587 595 $table_attribute_options = $wpdb->prefix . 'weareplanet_attribute_options'; //phpcs:ignore 588 596 589 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.597 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 590 598 $result = $wpdb->query( $wpdb->prepare( "SHOW COLUMNS FROM $table_transaction_info LIKE %s", 'user_failure_message' ) ); 591 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .599 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 592 600 593 601 if ( 0 === $result ) { 594 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.602 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 595 603 $result = $wpdb->query( "ALTER TABLE $table_transaction_info ADD COLUMN `user_failure_message` VARCHAR(2047) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER failure_reason" ); 596 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .604 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 597 605 598 606 if ( false === $result ) { … … 601 609 } 602 610 // Do not use foreign keys to reference attribute to cascade deletion, as some shop still run with MyISAM enginge as default. 603 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.611 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 604 612 $result = $wpdb->query( 605 613 "CREATE TABLE IF NOT EXISTS $table_attribute_options( … … 611 619 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" 612 620 ); 613 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .621 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 614 622 615 623 if ( false == $result ) { … … 703 711 global $wpdb; 704 712 // rollback table rename if there are issues. 705 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.713 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 706 714 $wpdb->query( 'START TRANSACTION' ); //phpcs:ignore 707 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .715 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 708 716 $table_stament = 'Tables_in_' . $wpdb->dbname; 709 717 710 718 foreach ( $table_rename_map as $old_table_name => $new_table_name ) { 711 719 // check old table exists. 712 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.720 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 713 721 $old_table_result = $wpdb->get_row( 714 722 $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $old_table_name ) 715 723 ); 716 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .724 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 717 725 718 726 if ( $old_table_result ) { 719 727 // check new table doesn't exist, if it does there's a problem!. 720 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.728 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 721 729 $new_table_result = $wpdb->get_row( 722 730 $wpdb->prepare( "SHOW TABLES WHERE $table_stament = %s", $new_table_name ) 723 731 ); 724 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .732 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 725 733 726 734 if ( ! $new_table_result ) { 727 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.735 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 728 736 $result = $wpdb->query( "RENAME TABLE $old_table_name TO $new_table_name" ); 729 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .737 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 730 738 if ( false === $result ) { 731 739 throw new Exception( esc_html( $wpdb->last_error ) ); … … 762 770 */ 763 771 public static function update_1_0_10_remove_previous_min_version() { 764 delete_metadata( 'user', 0, "weareplanet-previous-wc-min-version", '', true ); 772 delete_metadata( 'user', 0, 'weareplanet-previous-wc-min-version', '', true ); 773 } 774 775 /** 776 * Enforces payload signatures on webhook listeners. 777 */ 778 public static function update_1_0_11_enforce_signed_webhook_listeners() { 779 WC_WeArePlanet_Service_Webhook::instance()->enforce_signed_listeners(); 780 } 781 782 /** 783 * Clear the language cache, which earlier versions filled with languages without IETF codes. 784 * Only the cache is removed, it is rebuilt on the next access. 785 */ 786 public static function update_1_0_12_clear_language_cache() { 787 WC_WeArePlanet_Helper::instance()->delete_language_transient(); 765 788 } 766 789 } -
weareplanet/trunk/includes/class-wc-weareplanet-order-reference.php
r3288388 r3740659 1 1 <?php 2 3 2 /** 4 3 * Plugin Name: WeArePlanet -
weareplanet/trunk/includes/class-wc-weareplanet-order-status-adapter.php
r3463230 r3740659 23 23 * based on the transaction statuses in WeArePlanet. 24 24 */ 25 class WC_WeArePlanet_Order_Status_Adapter 26 { 25 class WC_WeArePlanet_Order_Status_Adapter { 27 26 /** 28 27 * Constants for WeArePlanet transaction statuses. 29 28 */ 30 const WEAREPLANET_STATUS_PENDING = 'pending';31 const WEAREPLANET_STATUS_CONFIRMED = 'confirmed';29 const WEAREPLANET_STATUS_PENDING = 'pending'; 30 const WEAREPLANET_STATUS_CONFIRMED = 'confirmed'; 32 31 const WEAREPLANET_STATUS_PROCESSING = 'processing'; 33 32 const WEAREPLANET_STATUS_AUTHORIZED = 'authorized'; 34 const WEAREPLANET_STATUS_COMPLETED = 'completed';35 const WEAREPLANET_STATUS_FAILED = 'failed';36 const WEAREPLANET_STATUS_VOIDED = 'voided';37 const WEAREPLANET_STATUS_FULFILL = 'fulfill';38 const WEAREPLANET_STATUS_DECLINE = 'decline';33 const WEAREPLANET_STATUS_COMPLETED = 'completed'; 34 const WEAREPLANET_STATUS_FAILED = 'failed'; 35 const WEAREPLANET_STATUS_VOIDED = 'voided'; 36 const WEAREPLANET_STATUS_FULFILL = 'fulfill'; 37 const WEAREPLANET_STATUS_DECLINE = 'decline'; 39 38 40 39 const WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX = 'weareplanet_order_status_mapping_'; 41 const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX = 'weareplanet_custom_order_status_';40 const WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX = 'weareplanet_custom_order_status_'; 42 41 /** 43 42 * Stores the status mappings loaded from the database. … … 52 51 * Initializes the settings and adds the filter for updating order status. 53 52 */ 54 public function __construct() 55 { 53 public function __construct() { 56 54 $this->initialize_filters(); 57 55 $this->initialize_status_mappings(); … … 61 59 * Initialise filters and actions. 62 60 */ 63 public static function init(): void 64 { 61 public static function init(): void { 65 62 add_action( 'plugins_loaded', array( __CLASS__, 'register_weareplanet_service_status_adapter' ) ); 66 63 } … … 74 71 * @return void 75 72 */ 76 public static function register_weareplanet_service_status_adapter(): void 77 { 73 public static function register_weareplanet_service_status_adapter(): void { 78 74 new WC_WeArePlanet_Order_Status_Adapter(); 79 75 } … … 82 78 * Initialize filters. 83 79 */ 84 private function initialize_filters(): void 85 { 80 private function initialize_filters(): void { 86 81 add_filter( 'weareplanet_default_order_status_mappings', array( $this, 'get_default_status_mappings' ) ); 87 82 add_filter( 'weareplanet_woocommerce_statuses', array( $this, 'get_all_woocommerce_statuses' ) ); … … 93 88 add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'get_order_status_on_payment_complete' ), 10, 3 ); 94 89 95 // tests.90 // tests. 96 91 // CPT-based orders. 97 add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_shop_order'), 20, 1 );98 add_action( 'handle_bulk_actions-edit-shop_order', array( $this, 'bulk_process_custom_status'), 20, 3 );92 add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_shop_order' ), 20, 1 ); 93 add_action( 'handle_bulk_actions-edit-shop_order', array( $this, 'bulk_process_custom_status' ), 20, 3 ); 99 94 // HPOS orders. 100 add_filter( 'bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_actions_shop_order'), 20, 1 );101 add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_process_custom_status'), 20, 3 );95 add_filter( 'bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_actions_shop_order' ), 20, 1 ); 96 add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', array( $this, 'bulk_process_custom_status' ), 20, 3 ); 102 97 } 103 98 … … 133 128 global $wpdb; 134 129 135 $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE. 136 $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A ); 137 138 //Build the array with the desired structure. 130 $cache_key = 'weareplanet_custom_order_statuses'; 131 $cache_group = 'weareplanet'; 132 133 $results = wp_cache_get( $cache_key, $cache_group ); 134 135 if ( $results === false ) { 136 $prefix = self::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; //We use % as wildcard for LIKE. 137 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 138 $results = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE %s", $prefix ), ARRAY_A ); 139 140 wp_cache_set( $cache_key, $results, $cache_group, HOUR_IN_SECONDS ); 141 } 142 143 // Build the array with the desired structure. 139 144 foreach ( $results as $row ) { 140 145 $status_label = ucfirst( str_replace( array( 'wc-', '_' ), array( '', ' ' ), $row['option_value'] ) ); 146 141 147 $order_statuses[ $row['option_value'] ] = $status_label; 142 148 } … … 161 167 ); 162 168 163 $order_statuses_without_prefix = array_map( function( $status ) { 164 return str_replace( 'wc-', '', $status ); 165 }, array_values( $default_mappings ) ); 166 167 return array_merge($order_statuses, $order_statuses_without_prefix); 169 $order_statuses_without_prefix = array_map( 170 function ( $status ) { 171 return str_replace( 'wc-', '', $status ); 172 }, 173 array_values( $default_mappings ) 174 ); 175 176 return array_merge( $order_statuses, $order_statuses_without_prefix ); 168 177 } 169 178 … … 171 180 * Loads the status mappings from the database or initializes them if not present. 172 181 */ 173 private function initialize_status_mappings(): void 174 { 182 private function initialize_status_mappings(): void { 175 183 $is_custom_mapping_enabled = WC_WeArePlanet_Helper::is_custom_status_mapping_enabled(); 176 184 $default_mappings = apply_filters( 'weareplanet_default_order_status_mappings', array() ); … … 203 211 * @return bool 204 212 */ 205 private function is_custom_order_status( string $order_status ): bool 206 { 213 private function is_custom_order_status( string $order_status ): bool { 207 214 return strpos( $order_status, 'wc-wearep-' ) === 0 || strpos( $order_status, 'wearep-' ) === 0; 208 215 } … … 214 221 * @return string 215 222 */ 216 private function ensure_status_has_prefix( string $status ): string 217 { 223 private function ensure_status_has_prefix( string $status ): string { 218 224 if ( '' === $status ) { 219 225 return $status; … … 236 242 * @return void 237 243 */ 238 public function store_default_status_mappings_on_database(): void 239 { 244 public function store_default_status_mappings_on_database(): void { 240 245 $default_mappings = $this->get_default_status_mappings(); 241 246 … … 255 260 * 256 261 * WooCommerce introduced the `OrderInternalStatus` constants in version 9.6.0. 257 * To maintain compatibility with earlier versions, string values are used as a fallback.262 * To maintain compatibility with earlier versions, string values are used as a fallback. 258 263 * This is the interface to use in next versions Automattic\WooCommerce\Enums\OrderInternalStatus 259 264 * … … 276 281 * @return array 277 282 */ 278 public function get_default_status_mappings() : array 279 { 283 public function get_default_status_mappings(): array { 280 284 $default_mappings = array( 281 285 self::WEAREPLANET_STATUS_PENDING => 'wc-pending', … … 309 313 * @return array 310 314 */ 311 public function get_legacy_default_status_mappings() : array 312 { 315 public function get_legacy_default_status_mappings(): array { 313 316 return array( 314 317 self::WEAREPLANET_STATUS_CONFIRMED => 'wearep-redirected', … … 323 326 * @return array 324 327 */ 325 public function get_all_woocommerce_statuses(): array 326 { 328 public function get_all_woocommerce_statuses(): array { 327 329 return wc_get_order_statuses(); 328 330 } … … 333 335 * @return array 334 336 */ 335 public function get_weareplanet_statuses(): array 336 { 337 public function get_weareplanet_statuses(): array { 337 338 return array( 338 339 self::WEAREPLANET_STATUS_PENDING => ucwords( self::WEAREPLANET_STATUS_PENDING ), … … 354 355 * @return string|null The corresponding WooCommerce order status or null if not found. 355 356 */ 356 private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string 357 { 357 private function map_weareplanet_status_to_woocommerce( ?string $status ): ?string { 358 358 if ( null === $status || '' === $status ) { 359 359 return $status; … … 361 361 362 362 if ( empty( $this->settings ) ) { 363 return $status; // Return the current status if there are no mappings available.364 } 365 366 // Search in 'transaction_status' first.363 return $status; // Return the current status if there are no mappings available. 364 } 365 366 // Search in 'transaction_status' first. 367 367 foreach ( $this->settings as $setting ) { 368 if ( $setting['transaction_status'] === strtolower( $status )) {369 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.368 if ( strtolower( $status ) === $setting['transaction_status'] ) { 369 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status. 370 370 } 371 371 } 372 372 373 // Fallback to legacy mappings if no match was found.373 // Fallback to legacy mappings if no match was found. 374 374 $legacy_mappings = $this->get_legacy_default_status_mappings(); 375 375 $transaction_status_key = array_search( $status, $legacy_mappings, true ); 376 376 377 if ( ! empty( $transaction_status_key ) ) {377 if ( ! empty( $transaction_status_key ) ) { 378 378 foreach ( $this->settings as $setting ) { 379 379 if ( $setting['transaction_status'] === $transaction_status_key ) { 380 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status.380 return str_replace( 'wc-', '', $setting['order_status'] ); // Return the mapped WooCommerce order status. 381 381 } 382 382 } 383 383 } 384 384 385 return str_replace( 'wc-', '', $status ); // Return legacy status or original (ensuring WC prefix is stripped).385 return str_replace( 'wc-', '', $status ); // Return legacy status or original (ensuring WC prefix is stripped). 386 386 } 387 387 … … 389 389 * Updates the status of a WooCommerce order based on the WeArePlanet status. 390 390 * 391 * @param WC_Order $order $order The WooCommerce order.391 * @param WC_Order $order $order The WooCommerce order. 392 392 * @param string|null $status The WeArePlanet transaction status. 393 * @param string|null $default status The WeArePlanet transaction status by default.394 * @param string $note Optional note to add when updating the status.393 * @param string|null $default_status The WeArePlanet transaction status by default. 394 * @param string $note Optional note to add when updating the status. 395 395 * @param @param bool $manual Whether this is a manual order status change. 396 396 */ 397 public function update_order_status( WC_Order $order, ?string $status, ?string $default_status, string $note = '', bool $manual = false ): void 398 { 397 public function update_order_status( 398 WC_Order $order, 399 ?string $status, 400 ?string $default_status, 401 string $note = '', 402 bool $manual = false 403 ): void { 399 404 // If status is empty. 400 if ( $status === null && $order !== null) {405 if ( null === $status && null !== $order ) { 401 406 $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); 402 407 if ( $transaction_info ) { … … 419 424 $new_status = $should_force_completed ? 'completed' : $this->map_weareplanet_status_to_woocommerce( $status ); 420 425 421 if ( ! empty( $new_status ) && !empty( $order ) ) {426 if ( ! empty( $new_status ) && ! empty( $order ) ) { 422 427 $order->update_status( $new_status, $note, $manual ); 423 428 // Apply a post-update filter to allow modifications after updating the status. … … 430 435 * and return the order status accordingly when the order is fulfill. 431 436 * 432 * @param string $status The default order status (processing or completed).433 * @param int $order_id The WooCommerce order ID.437 * @param string $status The default order status (processing or completed). 438 * @param int $order_id The WooCommerce order ID. 434 439 * @param WC_Order $order The WooCommerce order object. 435 440 * @return string The updated order status. 436 441 */ 437 public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string 438 { 442 public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string { 439 443 $change_setting_enabled = 'yes' === get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_CHANGE_ORDER_STATUS ); 440 444 $is_virtual_order = WC_WeArePlanet_Helper::is_order_virtual( $order ); … … 448 452 } 449 453 450 // Check if the transaction status is mapped in WooCommerce 454 // Check if the transaction status is mapped in WooCommerce. 451 455 $mapped_status = $this->map_weareplanet_status_to_woocommerce( \WeArePlanet\Sdk\Model\TransactionState::FULFILL ); 452 456 453 457 if ( ! empty( $mapped_status ) ) { 454 return $mapped_status; // Return the mapped WooCommerce status 458 return $mapped_status; // Return the mapped WooCommerce status. 455 459 } 456 460 … … 472 476 * @return string|null The mapped WooCommerce order status, or null if no mapping is found. 473 477 */ 474 public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string 475 { 478 public function get_wc_status_for_transaction( ?string $weareplanet_status ): ?string { 476 479 if ( null === $weareplanet_status || '' === $weareplanet_status ) { 477 480 return null; -
weareplanet/trunk/includes/class-wc-weareplanet-return-handler.php
r3288388 r3740659 46 46 $order_id = absint( wp_unslash( $_GET['order_id'] ) ); //phpcs:ignore 47 47 $order = WC_Order_Factory::get_order( $order_id ); 48 $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); 48 $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // phpcs:ignore 49 49 if ( $order->get_id() === $order_id && $order->get_order_key() === $order_key ) { 50 50 switch ( $action ) { -
weareplanet/trunk/includes/class-wc-weareplanet-subscription-gateway.php
r3463230 r3740659 97 97 public function process_scheduled_subscription_payment( $amount_to_charge, WC_Order $order ) { 98 98 try { 99 $token_data = $this->get_token_data_from_order( $order);99 $token_data = $this->get_token_data_from_order( $order ); 100 100 101 101 $token_space_id = $token_data['_weareplanet_subscription_space_id']; 102 $token_id = $token_data['_weareplanet_subscription_token_id'];102 $token_id = $token_data['_weareplanet_subscription_token_id']; 103 103 104 104 $transaction_service = WC_WeArePlanet_Service_Transaction::instance(); … … 107 107 if ( $transaction_info->get_id() > 0 ) { 108 108 $existing_transaction = $transaction_service->get_transaction( $transaction_info->get_space_id(), $transaction_info->get_id() ); 109 if ( $existing_transaction->getState() != \WeArePlanet\Sdk\Model\TransactionState::PENDING ) {109 if ( $existing_transaction->getState() !== \WeArePlanet\Sdk\Model\TransactionState::PENDING ) { 110 110 return; 111 111 } … … 162 162 if ( ! isset( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) || empty( $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) ) { 163 163 throw new Exception( esc_html__( 'The WeArePlanet Space Id value is required.', 'woo-weareplanet' ) ); 164 } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) {164 } elseif ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $payment_meta['post_meta']['_weareplanet_subscription_space_id']['value'] ) { 165 165 throw new Exception( esc_html__( 'The WeArePlanet Space Id needs to be in the same space as configured in the main configuration.', 'woo-weareplanet' ) ); 166 166 } … … 180 180 */ 181 181 public function update_payment_method( $update, $new_payment_method, $subscription ) { 182 if ( $this->gateway->id == $new_payment_method ) {182 if ( $this->gateway->id === $new_payment_method ) { 183 183 $update = false; 184 184 add_filter( … … 212 212 * @param WC_Order $order Order. 213 213 * @return array 214 * /215 private function get_token_data_from_order($order)216 {217 $order_id = $order->get_id();218 $token_data = [];214 * @throws Exception Exception. 215 */ 216 private function get_token_data_from_order( $order ) { 217 $order_id = $order->get_id(); 218 $token_data = array(); 219 219 $token_data['_weareplanet_subscription_space_id'] = get_post_meta( $order_id, '_weareplanet_subscription_space_id', true ); 220 220 $token_data['_weareplanet_subscription_token_id'] = get_post_meta( $order_id, '_weareplanet_subscription_token_id', true ); 221 221 222 if ( ! isset($token_data['_weareplanet_subscription_space_id']) || isset($token_data['_weareplanet_subscription_token_id']) ) {222 if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) || isset( $token_data['_weareplanet_subscription_token_id'] ) ) { 223 223 224 224 $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); 225 // In theory, each of the array elements should contain the same token and space data 226 $subscription_object = array_pop( $subscriptions);227 $subscription_meta = $subscription_object->get_meta_data();228 $token_data = [];229 $subscription_keys = [225 // In theory, each of the array elements should contain the same token and space data. 226 $subscription_object = array_pop( $subscriptions ); 227 $subscription_meta = $subscription_object->get_meta_data(); 228 $token_data = array(); 229 $subscription_keys = array( 230 230 '_weareplanet_subscription_space_id', 231 '_weareplanet_subscription_token_id' 232 ];233 234 foreach ( $subscription_meta as $meta_data ) {231 '_weareplanet_subscription_token_id', 232 ); 233 234 foreach ( $subscription_meta as $meta_data ) { 235 235 $contained_data = $meta_data->get_data(); 236 if ( in_array( $contained_data['key'], $subscription_keys ) ) {237 $token_data[ $contained_data['key']] = $contained_data['value'];236 if ( in_array( $contained_data['key'], $subscription_keys ) ) { 237 $token_data[ $contained_data['key'] ] = $contained_data['value']; 238 238 } 239 239 } 240 240 } 241 241 242 if ( ! isset($token_data['_weareplanet_subscription_space_id']) ) {242 if ( ! isset( $token_data['_weareplanet_subscription_space_id'] ) ) { 243 243 $order->update_status( 'failed', esc_html__( 'No Space Id is found.', 'woo-weareplanet' ) ); 244 throw new Exception( 'Missing space id details');245 } 246 247 if ( ! isset($token_data['_weareplanet_subscription_token_id']) ) {244 throw new Exception( 'Missing space id details' ); 245 } 246 247 if ( ! isset( $token_data['_weareplanet_subscription_token_id'] ) ) { 248 248 $order->update_status( 'failed', esc_html__( 'No Token Id is found.', 'woo-weareplanet' ) ); 249 throw new Exception( 'Missing token id');250 } 251 252 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) != $token_data['_weareplanet_subscription_space_id'] ) {249 throw new Exception( 'Missing token id' ); 250 } 251 252 if ( get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ) !== $token_data['_weareplanet_subscription_space_id'] ) { 253 253 $order->update_status( 'failed', esc_html__( 'The token space and the configured space are not equal.', 'woo-weareplanet' ) ); 254 throw new Exception( 'Token space does not match configured space');254 throw new Exception( 'Token space does not match configured space' ); 255 255 } 256 256 … … 297 297 public function store_gateway_result_in_globals( $result, $subscription ) { 298 298 if ( isset( $result['weareplanet'] ) ) { 299 $GLOBALS[' _wc_weareplanet_subscription_gateway_result'] = $result;299 $GLOBALS['wc_weareplanet_subscription_gateway_result'] = $result; 300 300 return array( 301 'result' => $result['result'],301 'result' => $result['result'], 302 302 'redirect' => 'wc_weareplanet_subscription_redirect', 303 303 ); … … 314 314 */ 315 315 public function create_json_response( $location, $status ) { 316 $location = basename( $location);317 if ( 'wc_weareplanet_subscription_redirect' == $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) {316 $location = basename( $location ); 317 if ( 'wc_weareplanet_subscription_redirect' === $location && isset( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ) ) { 318 318 wp_send_json( $GLOBALS['_wc_weareplanet_subscription_gateway_result'] ); 319 319 exit; -
weareplanet/trunk/includes/class-wc-weareplanet-subscription.php
r3433358 r3740659 54 54 } 55 55 56 /** 57 * Boot the subscription integration. 58 * 59 * @return void 60 */ 56 61 public function boot() { 57 62 add_filter( … … 466 471 public function fulfill_in_progress( \WeArePlanet\Sdk\Model\Transaction $transaction, $order ) { 467 472 if ( wcs_order_contains_subscription( $order, array( 'parent', 'resubscribe', 'switch', 'renewal' ) ) ) { 468 $GLOBALS[' _wc_weareplanet_subscription_fulfill'] = true;473 $GLOBALS['wc_weareplanet_subscription_fulfill'] = true; 469 474 } 470 475 } … … 478 483 */ 479 484 public function add_valid_order_statuses_for_subscription_completion( $statuses, $order = null ) { 480 if ( isset( $GLOBALS[' _wc_weareplanet_subscription_fulfill'] ) ) {485 if ( isset( $GLOBALS['wc_weareplanet_subscription_fulfill'] ) ) { 481 486 $statuses[] = 'wearep-waiting'; 482 487 $statuses[] = 'wearep-manual'; … … 490 495 * @param WC_WeArePlanet_Entity_Transaction_Info $info Info. 491 496 * @param \WeArePlanet\Sdk\Model\Transaction $transaction Transaction. 492 * @param WC_Order $order O der.497 * @param WC_Order $order Order. 493 498 * @return WC_WeArePlanet_Entity_Transaction_Info 494 499 */ … … 565 570 */ 566 571 public function before_renewal_setup_cart( $subscriptions, $order ) { 567 $GLOBALS[' _wc_weareplanet_renewal_cart_setup'] = true;572 $GLOBALS['wc_weareplanet_renewal_cart_setup'] = true; 568 573 } 569 574 … … 576 581 */ 577 582 public function after_renewal_setup_cart( $subscriptions, $order ) { 578 $GLOBALS[' _wc_weareplanet_renewal_cart_setup'] = false;583 $GLOBALS['wc_weareplanet_renewal_cart_setup'] = false; 579 584 } 580 585 … … 586 591 */ 587 592 public function method_available_for_cart_renewal( $available ) { 588 if ( isset( $GLOBALS[' _wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['_wc_weareplanet_renewal_cart_setup'] ) {593 if ( isset( $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) && $GLOBALS['wc_weareplanet_renewal_cart_setup'] ) { 589 594 return true; 590 595 } … … 626 631 } 627 632 } 628 629 -
weareplanet/trunk/includes/class-wc-weareplanet-unique-id.php
r3673687 r3740659 33 33 array( 34 34 __CLASS__, 35 'copy_un qiue_id_to_order_item',35 'copy_unique_id_to_order_item', 36 36 ), 37 37 10, … … 42 42 array( 43 43 __CLASS__, 44 'copy_un qiue_id_to_order_fee',44 'copy_unique_id_to_order_fee', 45 45 ), 46 46 10, … … 51 51 array( 52 52 __CLASS__, 53 'copy_un qiue_id_to_order_shipping',53 'copy_unique_id_to_order_shipping', 54 54 ), 55 55 10, … … 81 81 * @return WC_Order_Item_Product $item item 82 82 */ 83 public static function copy_un qiue_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, ?WC_Order $order = null ) { //phpcs:ignore83 public static function copy_unique_id_to_order_item( WC_Order_Item_Product $item, $cart_item_key, $values, WC_Order $order = null ) { //phpcs:ignore 84 84 // We do not use the cart_item_key as it is deprecated. 85 85 $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true ); … … 97 97 * @return WC_Order_Item_Shipping $item item 98 98 */ 99 public static function copy_un qiue_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, ?WC_Order $order = null ) { //phpcs:ignore99 public static function copy_unique_id_to_order_shipping( WC_Order_Item_Shipping $item, $package_key, $package, WC_Order $order = null ) { //phpcs:ignore 100 100 $item->add_meta_data( '_weareplanet_unique_line_item_id', self::get_uuid(), true ); 101 101 return $item; … … 112 112 * @return WC_Order_Item_Shipping $item item 113 113 */ 114 public static function copy_un qiue_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore114 public static function copy_unique_id_to_order_fee( WC_Order_Item_Fee $item, $fee_key, $fee, ?WC_Order $order = null ) { //phpcs:ignore 115 115 $unique_id = null; 116 116 if ( $fee->amount < 0 ) { -
weareplanet/trunk/includes/class-wc-weareplanet-webhook-handler.php
r3288388 r3740659 72 72 $raw_post_data = $wp_filesystem->get_contents( 'php://input' ); 73 73 $signature = isset( $_SERVER['HTTP_X_SIGNATURE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_SIGNATURE'] ) ) : ''; 74 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler 74 75 set_error_handler( array( __CLASS__, 'handle_webhook_errors' ) ); 75 76 try { … … 79 80 $webhook_service = WC_WeArePlanet_Service_Webhook::instance(); 80 81 81 // Handling of payloads without a signature (legacy method). 82 // TODO add config to disable strategy/use default webhooks 83 // Deprecated since 3.0.12. 82 // Handling of payloads without a signature removed since 3.4.9. 83 // Log received unsigned webhook payloads and request that webhook signature to be enabled. 84 84 if ( empty( $signature ) ) { 85 $webhook_model = $webhook_service->get_webhook_entity_for_id( $request->get_listener_entity_id() ); 86 $webhook_handler_class_name = $webhook_model->get_handler_class_name(); 87 $webhook_handler = $webhook_handler_class_name::instance(); 88 $webhook_handler->process( $request ); 85 $signature_missing_message = 'Webhook ' . $request->get_listener_entity_technical_name() 86 . ' lacked a signature. Enable payload signature and state for ' 87 . $request->get_listener_entity_technical_name() . ' webhook listener.'; 88 WooCommerce_WeArePlanet::instance()->log( $signature_missing_message, WC_Log_Levels::ERROR ); 89 echo esc_textarea( $signature_missing_message ); 89 90 } 90 91 -
weareplanet/trunk/includes/class-wc-weareplanet-zero-gateway.php
r3321215 r3740659 1 1 <?php 2 /** 3 * Plugin Name: WeArePlanet 4 * Author: Planet Merchant Services Ltd 5 * Text Domain: weareplanet 6 * Domain Path: /languages/ 7 * 8 * WeArePlanet 9 * This plugin will add support for all WeArePlanet payments methods and connect the WeArePlanet servers to your WooCommerce webshop (https://www.weareplanet.com/). 10 * 11 * @category Class 12 * @package WeArePlanet 13 * @author Planet Merchant Services Ltd (https://www.weareplanet.com) 14 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0) 15 */ 2 16 3 17 if ( ! defined( 'ABSPATH' ) ) { … … 5 19 } 6 20 21 /** 22 * Class WC_WeArePlanet_Zero_Gateway. 23 * This class handles the zero payment gateway of WeArePlanet 24 * 25 * @class WC_WeArePlanet_Zero_Gateway 26 */ 7 27 class WC_WeArePlanet_Zero_Gateway extends WC_Payment_Gateway { 8 28 9 29 public const ZERO_PAYMENT_CONF_ID = 999999; 10 30 31 /** 32 * Constructor for the gateway. 33 */ 11 34 public function __construct() { 12 35 $this->id = 'weareplanet_zero'; … … 24 47 25 48 add_action( 26 'woocommerce_update_options_payment_gateways_' . $this->id,27 array( $this, 'process_admin_options' )49 'woocommerce_update_options_payment_gateways_' . $this->id, 50 array( $this, 'process_admin_options' ) 28 51 ); 29 52 30 53 add_filter( 31 'woocommerce_available_payment_gateways',32 array( $this, 'hide_gateways_for_zero_order_total' )54 'woocommerce_available_payment_gateways', 55 array( $this, 'hide_gateways_for_zero_order_total' ) 33 56 ); 34 57 } 35 58 59 /** 60 * Initialize form fields for the gateway settings. 61 */ 36 62 public function init_form_fields() { 37 63 $this->form_fields = array( 38 'enabled' => array(39 'title' => __( 'Enable/Disable', 'woo-weareplanet' ),40 'type' => 'checkbox',41 'label' => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ),42 'default' => 'yes',43 ),44 'title' => array(45 'title' => __( 'Title', 'woo-weareplanet' ),46 'type' => 'text',47 'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ),48 'default' => __( 'No Payment Required', 'woo-weareplanet' ),49 'desc_tip' => true,50 ),64 'enabled' => array( 65 'title' => __( 'Enable/Disable', 'woo-weareplanet' ), 66 'type' => 'checkbox', 67 'label' => __( 'Enable No Payment Required Gateway', 'woo-weareplanet' ), 68 'default' => 'yes', 69 ), 70 'title' => array( 71 'title' => __( 'Title', 'woo-weareplanet' ), 72 'type' => 'text', 73 'description' => __( 'This controls the title seen by the customer during checkout.', 'woo-weareplanet' ), 74 'default' => __( 'No Payment Required', 'woo-weareplanet' ), 75 'desc_tip' => true, 76 ), 51 77 ); 52 78 } 53 79 80 /** 81 * Check if the gateway is available for the current order. 82 * 83 * @return bool True if available, false otherwise. 84 */ 54 85 public function is_available() { 55 if ( isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {86 if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) {// phpcs:disable WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag. 56 87 $order_id = get_query_var( 'order-pay' ); 57 88 $order = wc_get_order( $order_id ); … … 63 94 return false; 64 95 } 65 return ( WC()->cart && WC()->cart->total == 0 ) && $this->enabled === 'yes';96 return ( WC()->cart && WC()->cart->total == 0 ) && 'yes' === $this->enabled; 66 97 } 67 98 99 /** 100 * Get the payment configuration ID for the zero payment gateway. 101 * 102 * @return int The payment configuration ID. 103 */ 68 104 public function get_payment_configuration_id() { 69 105 // This can be a fake or static ID just to satisfy the interface. … … 71 107 } 72 108 109 /** 110 * Process the payment for the order. 111 * 112 * @param int $order_id The ID of the order being processed. 113 * @return array An array containing the result and redirect URL. 114 */ 73 115 public function process_payment( $order_id ) { 74 116 $order = wc_get_order( $order_id ); … … 77 119 78 120 return array( 79 'result' => 'success',80 'redirect' => $this->get_return_url( $order ),121 'result' => 'success', 122 'redirect' => $this->get_return_url( $order ), 81 123 ); 82 124 } 83 125 126 /** 127 * Hide other payment gateways when the order total is zero. 128 * 129 * @param array $available_gateways The available payment gateways. 130 * @return array The modified list of available payment gateways. 131 */ 84 132 public function hide_gateways_for_zero_order_total( $available_gateways ) { 85 133 if ( is_admin() ) { … … 87 135 } 88 136 89 if ( isset($_GET['pay_for_order']) && boolval($_GET['pay_for_order']) === true) {137 if ( isset( $_GET['pay_for_order'] ) && boolval( $_GET['pay_for_order'] ) === true ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $pay_for_order is a woocommerce read-only URL param. Value is only used as a bool flag. 90 138 $order_id = get_query_var( 'order-pay' ); 91 139 $order = wc_get_order( $order_id ); … … 97 145 98 146 $has_subscription = self::cart_has_subscription(); 99 if ( WC()->cart && WC()->cart->total == 0 && ! $has_subscription ) {147 if ( WC()->cart && WC()->cart->total == 0 && ! $has_subscription ) { 100 148 foreach ( $available_gateways as $gateway_id => $gateway ) { 101 if ( $gateway_id !== 'weareplanet_zero') {149 if ( 'weareplanet_zero' !== $gateway_id ) { 102 150 unset( $available_gateways[ $gateway_id ] ); 103 151 } … … 108 156 } 109 157 158 /** 159 * Check if the cart contains any subscription products. 160 * 161 * @return bool True if the cart has a subscription, false otherwise. 162 */ 110 163 public static function cart_has_subscription() { 111 164 if ( ! function_exists( 'WC' ) || ! WC()->cart ) { … … 113 166 } 114 167 115 $subscription_classes = [116 'WC_Subscription_Product',117 'WC_Product_Subscription',118 'WC_Product_Subscription_Variation',119 ];168 $subscription_classes = array( 169 'WC_Subscription_Product', 170 'WC_Product_Subscription', 171 'WC_Product_Subscription_Variation', 172 ); 120 173 121 174 foreach ( WC()->cart->get_cart() as $cart_item ) { -
weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-attribute-options.php
r3288388 r3740659 71 71 global $wpdb; 72 72 $table = $wpdb->prefix . self::get_table_name(); 73 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.73 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 74 74 $result = $wpdb->get_row( 75 75 $wpdb->prepare( … … 79 79 ARRAY_A 80 80 ); 81 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .81 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 82 82 if ( null !== $result ) { 83 83 return new self( $result ); -
weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-method-configuration.php
r3288388 r3740659 82 82 83 83 $table = $wpdb->prefix . self::get_table_name(); 84 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.84 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 85 85 $result = $wpdb->get_row( 86 86 $wpdb->prepare( … … 91 91 ARRAY_A 92 92 ); 93 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .93 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 94 94 95 95 if ( null !== $result ) { -
weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-refund-job.php
r3288388 r3740659 98 98 99 99 $table = $wpdb->prefix . self::get_table_name(); 100 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.100 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 101 101 $result = $wpdb->get_row( 102 102 $wpdb->prepare( … … 107 107 ARRAY_A 108 108 ); 109 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .109 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 110 110 if ( null !== $result ) { 111 111 return new self( $result ); -
weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-token-info.php
r3288388 r3740659 74 74 global $wpdb; 75 75 $table = $wpdb->prefix . self::get_table_name(); 76 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.76 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 77 77 $result = $wpdb->get_row( 78 78 $wpdb->prepare( … … 83 83 ARRAY_A 84 84 ); 85 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.85 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 86 86 if ( null !== $result ) { 87 87 return new self( $result ); -
weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-transaction-info.php
r3288388 r3740659 139 139 global $wpdb; 140 140 $table = $wpdb->prefix . self::get_table_name(); 141 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.141 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 142 142 $result = $wpdb->get_row( 143 143 $wpdb->prepare( … … 148 148 ARRAY_A 149 149 ); 150 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .150 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 151 151 if ( null !== $result ) { 152 152 return new self( $result ); … … 165 165 global $wpdb; 166 166 $table = $wpdb->prefix . self::get_table_name(); 167 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.167 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 168 168 $result = $wpdb->get_row( 169 169 $wpdb->prepare( … … 173 173 ARRAY_A 174 174 ); 175 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .175 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 176 176 if ( null !== $result ) { 177 177 return new self( $result ); -
weareplanet/trunk/includes/entity/class-wc-weareplanet-entity-void-job.php
r3288388 r3740659 93 93 global $wpdb; 94 94 $table = $wpdb->prefix . self::get_table_name(); 95 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.95 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 96 96 $result = $wpdb->get_row( //phpcs:ignore 97 97 $wpdb->prepare( … … 102 102 ARRAY_A 103 103 ); 104 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .104 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 105 105 if ( null !== $result ) { 106 106 return new self( $result ); … … 120 120 121 121 $table = $wpdb->prefix . self::get_table_name(); 122 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.122 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 123 123 $result = $wpdb->get_var( 124 124 $wpdb->prepare( … … 129 129 ) 130 130 ); 131 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .131 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 132 132 return $result; 133 133 } … … 143 143 global $wpdb; 144 144 $table = $wpdb->prefix . self::get_table_name(); 145 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.145 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 146 146 $result = $wpdb->get_row( 147 147 $wpdb->prepare( … … 153 153 ARRAY_A 154 154 ); 155 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .155 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 156 156 if ( null !== $result ) { 157 157 return new self( $result ); … … 172 172 $time->sub( new DateInterval( 'PT10M' ) ); 173 173 $table = $wpdb->prefix . self::get_table_name(); 174 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Values are escaped in $wpdb->prepare.174 // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Values are escaped in $wpdb->prepare. 175 175 $db_results = $wpdb->get_results( 176 176 $wpdb->prepare( … … 181 181 ARRAY_A 182 182 ); 183 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare .183 // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, PluginCheck.Security.DirectDB.UnescapedDBParameter. 184 184 $result = array(); 185 185 if ( is_array( $db_results ) ) { -
weareplanet/trunk/includes/packages/gift-card/class-wc-weareplanet-packages-gift-card.php
r3433358 r3740659 22 22 * This class provides constants for Gift Cards and serves as a placeholder for future improvements. 23 23 */ 24 class WC_WeArePlanet_Packages_Gift_Card 25 { 24 class WC_WeArePlanet_Packages_Gift_Card { 26 25 const WEAREPLANET_GIFT_CARD = 'Gift Card'; 27 26 } -
weareplanet/trunk/includes/provider/class-wc-weareplanet-provider-language.php
r3288388 r3740659 89 89 */ 90 90 protected function fetch_data() { 91 // LanguageService::all() decodes languages.json into associative arrays, which the 92 // ObjectSerializer cannot map onto models, so every language ends up without codes. 93 $sdk_service = new \ReflectionClass( \WeArePlanet\Sdk\Service\LanguageService::class ); 94 $json_file = dirname( $sdk_service->getFileName() ) . '/../languages.json'; 95 if ( is_readable( $json_file ) ) { 96 $languages = json_decode( file_get_contents( $json_file ) ); //phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents 97 if ( ! empty( $languages ) && is_array( $languages ) ) { 98 return \WeArePlanet\Sdk\ObjectSerializer::deserialize( $languages, '\WeArePlanet\Sdk\Model\RestLanguage[]' ); 99 } 100 } 91 101 $language_service = new \WeArePlanet\Sdk\Service\LanguageService( WC_WeArePlanet_Helper::instance()->get_api_client() ); 92 102 return $language_service->all(); -
weareplanet/trunk/includes/service/class-wc-weareplanet-service-line-item.php
r3477965 r3740659 273 273 * 274 274 * @param WC_Coupon|WC_Order_Item_Coupon $coupon The coupon object. 275 * @param float $total_discount_amount The amount of the coupon. 275 * @param float $total_discount_amount The amount of the coupon. 276 * @param array $items The items to calculate the proportional discount for. 276 277 * @return \WeArePlanet\Sdk\Model\LineItemCreate|null The line item created or null if the coupon is not valid. 277 278 */ 278 private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = []) {279 private function create_coupon_line_items( $coupon, float $total_discount_amount = 0, array $items = array() ) { 279 280 if ( ! $coupon instanceof WC_Coupon && ! $coupon instanceof WC_Order_Item_Coupon ) { 280 281 return array(); … … 317 318 * Calculate discount rates 318 319 * 320 * @param array $items items. 319 321 * @param float $total_discount_amount total_discount_amount. 320 322 * @return array 321 323 */ 322 324 private function calculate_discount_rates_proportionally( array $items, float $total_discount_amount ): array { 323 $tax_totals = [];325 $tax_totals = array(); 324 326 $total_amount = 0; 325 327 // If coupon line items are created from session, $items will always be an empty array. If from order, it will have said order line items. 326 $is_created_from_order = ! empty( $items);328 $is_created_from_order = ! empty( $items ); 327 329 328 330 // Check whether line items are no created from existing order. If not, line items are fetched from cart. 329 if ( ! $is_created_from_order ) {331 if ( ! $is_created_from_order ) { 330 332 $cart = WC()->cart; 331 333 $items = $cart->get_cart(); … … 340 342 // If product has no tax rates class set, then create a fake 0 rate one. 341 343 if ( empty( $tax_rates_class ) ) { 342 $tax_rates_class = [343 0 => [344 $tax_rates_class = array( 345 0 => array( 344 346 'rate' => 0, 345 ],346 ];347 ), 348 ); 347 349 } 348 350 … … 352 354 $line_total = ! $is_created_from_order ? $item['line_total'] : $item->get_total(); 353 355 $line_tax = ! $is_created_from_order ? $item['line_tax'] : $item->get_total_tax(); 354 $line_total_with_tax = floor( ($line_total + $line_tax) * 100) / 100;356 $line_total_with_tax = floor( ($line_total + $line_tax ) * 100 ) / 100; 355 357 356 358 if ( ! isset( $tax_totals[ $rate_id ] ) ) { 357 $tax_totals[ $rate_id ] = [359 $tax_totals[ $rate_id ] = array( 358 360 'total' => 0, 359 361 'rate_percentage' => $rate['rate'], 360 ];362 ); 361 363 } 362 364 363 $tax_totals[ $rate_id ]['total'] += floor( ($line_total_with_tax) * 100) / 100;365 $tax_totals[ $rate_id ]['total'] += floor( ( $line_total_with_tax ) * 100 ) / 100; 364 366 $total_amount += $line_total_with_tax; 365 367 } … … 367 369 368 370 if ( $total_amount <= 0 ) { 369 return [];370 } 371 372 $discounts = [];371 return array(); 372 } 373 374 $discounts = array(); 373 375 foreach ( $tax_totals as $rate_id => $data ) { 374 if ( $total_amount == 0) {376 if ( 0 === $total_amount ) { 375 377 // If $total_amount is 0, no proportional discounts are applied, as there is nothing to distribute. 376 378 $proportional_discount_amount = 0; 377 379 } else { 378 $proportional_discount_amount = floor( $total_discount_amount * ( $data['total'] / $total_amount ) * 100) / 100;380 $proportional_discount_amount = floor( $total_discount_amount * ( $data['total'] / $total_amount ) * 100 ) / 100; 379 381 } 380 382 381 383 if ( $proportional_discount_amount > 0 ) { 382 $discounts[] = [383 'rate_id' => $rate_id,384 'amount' => $proportional_discount_amount,385 'rate_percentage' => $data['rate_percentage'],386 ];384 $discounts[] = array( 385 'rate_id' => $rate_id, 386 'amount' => $proportional_discount_amount, 387 'rate_percentage' => $data['rate_percentage'], 388 ); 387 389 } 388 390 } … … 641 643 * Get items from backend. 642 644 * 643 * @param array $backend_items backend items.644 * @param mixed $amount amount.645 * @param array $backend_items backend items. 646 * @param mixed $amount amount. 645 647 * @param WC_Order $order order. 646 648 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] … … 660 662 * Creates the line items for the products 661 663 * 662 * @param array $backend_items backend items.664 * @param array $backend_items backend items. 663 665 * @param WC_Order $order order. 664 666 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] … … 753 755 * Returns the line items for fees. 754 756 * 755 * @param array $backend_items backend items.757 * @param array $backend_items backend items. 756 758 * @param WC_Order $order order. 757 759 * @return array … … 821 823 * Returns the line items for the shipping costs. 822 824 * 823 * @param array $backend_items backend items.825 * @param array $backend_items backend items. 824 826 * @param WC_Order $order order. 825 827 * @return array … … 999 1001 * Returns the line items from the given cart for order renewal. 1000 1002 * 1001 * @param WC_Order $order order.1002 * @param mixed $order_total Order total.1003 * @param WC_Order $order order. 1004 * @param mixed $order_total Order total. 1003 1005 * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction. 1004 1006 * … … 1023 1025 $gift_card_items = array(); 1024 1026 1025 $redeemed = WC()->session->get( '_wc_gc_giftcards', []);1027 $redeemed = WC()->session->get( '_wc_gc_giftcards', array() ); 1026 1028 1027 1029 if ( empty( $redeemed ) ) { … … 1045 1047 } 1046 1048 1047 // Receive the amount debited from the card for this order 1049 // Receive the amount debited from the card for this order. 1048 1050 $used_amount = $item['amount']; 1049 1051 … … 1052 1054 } 1053 1055 1054 // Prevent rounding errors from sdk 1056 // Prevent rounding errors from sdk. 1055 1057 $used_amount = round($used_amount, 2); 1056 1058 1057 // Create Line Items for gift cards 1059 // Create Line Items for gift cards. 1058 1060 $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate(); 1059 1061 $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) ); … … 1066 1068 $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT ); 1067 1069 1068 // Zero tax for gift card 1070 // Zero tax for gift card. 1069 1071 $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate( 1070 1072 array( … … 1084 1086 * Create gift card line items from an order object (used in backend or sync). 1085 1087 * 1086 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] 1087 */ 1088 protected function create_gift_card_line_items_from_order( $order) { 1088 * @param WC_Order $order order. 1089 * 1090 * @return \WeArePlanet\Sdk\Model\LineItemCreate[] 1091 */ 1092 protected function create_gift_card_line_items_from_order( $order ) { 1089 1093 if ( ! function_exists( 'WC_GC' ) ) { 1090 1094 return array(); … … 1093 1097 $gift_card_items = array(); 1094 1098 1095 // Get array of strings with codes used in current order1099 // Get array of strings with codes used in current order. 1096 1100 $used_codes = WC_GC()->order->get_gift_cards( $order ); 1097 1101 … … 1100 1104 } 1101 1105 1102 $order_gift_cards = [];1103 1104 // Initialize appropriate Gift Card Objects for each code1106 $order_gift_cards = array(); 1107 1108 // Initialize appropriate Gift Card Objects for each code. 1105 1109 foreach ( $used_codes['codes'] as $item ) { 1106 1110 $order_gift_cards[] = wc_gc_get_gift_card_by_code( $item ); … … 1111 1115 } 1112 1116 1113 $items = $order->get_items( 'gift_card');1117 $items = $order->get_items( 'gift_card' ); 1114 1118 1115 1119 foreach ( $items as $giftcard_item ) { … … 1128 1132 1129 1133 $line_item = new \WeArePlanet\Sdk\Model\LineItemCreate(); 1130 // WeArePlanet expects discounts as negative values 1134 // WeArePlanet expects discounts as negative values. 1131 1135 $line_item->setAmountIncludingTax( -1 * abs( $used_amount ) ); 1132 1136 /* translators: %s: gift card code */ … … 1138 1142 $line_item->setType( \WeArePlanet\Sdk\Model\LineItemType::DISCOUNT ); 1139 1143 1140 // Zero tax for gift card 1144 // Zero tax for gift card. 1141 1145 $tax_rate = new \WeArePlanet\Sdk\Model\TaxCreate( 1142 1146 array( -
weareplanet/trunk/includes/service/class-wc-weareplanet-service-token.php
r3433358 r3740659 111 111 return; 112 112 } 113 114 // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists 113 114 // need to add a safety check here to see if the $token_version->getPaymentConnectorConfiguration()->getPaymentMethodConfiguration() exists. 115 115 if ( $token_version->getPaymentConnectorConfiguration() === null ) { 116 116 return; -
weareplanet/trunk/includes/service/class-wc-weareplanet-service-transaction.php
r3463230 r3740659 90 90 * @throws Exception If the API client cannot be initialized. 91 91 */ 92 public function __construct() 93 { 92 public function __construct() { 94 93 $this->api_client = WC_WeArePlanet_Helper::instance()->get_api_client(); 95 94 } … … 503 502 */ 504 503 public function get_possible_payment_methods_for_cart() { 505 $payment Configurations = $this->get_possible_payment_methods( null );506 $payment Configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;507 508 return $payment Configurations;504 $payment_configurations = $this->get_possible_payment_methods( null ); 505 $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID; 506 507 return $payment_configurations; 509 508 } 510 509 … … 521 520 */ 522 521 public function get_possible_payment_methods_for_order( WC_Order $order ) { 523 $payment Configurations = $this->get_possible_payment_methods( $order );524 $payment Configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID;525 526 return $payment Configurations;522 $payment_configurations = $this->get_possible_payment_methods( $order ); 523 $payment_configurations[] = WC_WeArePlanet_Zero_Gateway::ZERO_PAYMENT_CONF_ID; 524 525 return $payment_configurations; 527 526 } 528 527 … … 569 568 * @param WC_Order $order order. 570 569 * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction transaction. 571 * @param bool $set_line_items Set line items.570 * @param bool $set_line_items Set line items. 572 571 * @throws WC_WeArePlanet_Exception_Invalid_Transaction_Amount WC_WeArePlanet_Exception_Invalid_Transaction_Amount. 573 572 */ … … 579 578 $transaction->setCustomerId( $this->get_customer_id() ); 580 579 $customer_note = $order->get_customer_note(); 581 if ( !empty($customer_note)) {582 $transaction->setMetaData( ['customerNotes' => $customer_note]);580 if ( ! empty( $customer_note ) ) { 581 $transaction->setMetaData( array( 'customerNotes' => $customer_note ) ); 583 582 } 584 583 $language = null; … … 786 785 * If no transaction exists, a new one is created. 787 786 * 787 * @param int|null $current_cart_id current cart id. 788 788 * @return \WeArePlanet\Sdk\Model\Transaction 789 789 * @throws Exception Exception. 790 790 */ 791 public function get_transaction_from_session( $current_cart_id = null ) {791 public function get_transaction_from_session( $current_cart_id = null ) { 792 792 793 793 if ( null === $current_cart_id ) { … … 910 910 * Load and update transaction for order. 911 911 * 912 * @param WC_Order $order order.912 * @param WC_Order $order order. 913 913 * @param WC_WeArePlanet_Entity_Transaction_Info $existing_transaction existing transaction. 914 914 * @return \WeArePlanet\Sdk\Model\Transaction|\WeArePlanet\Sdk\Model\TransactionCreate … … 1207 1207 * Set modified order line items. 1208 1208 * 1209 * @param WC_Order $order Order.1209 * @param WC_Order $order Order. 1210 1210 * @param mixed $order_total Order total. 1211 1211 * @param \WeArePlanet\Sdk\Model\AbstractTransactionPending $transaction Transaction. … … 1221 1221 * 1222 1222 * @param WC_Order $order Order. 1223 * @param mixed $order_total Order total.1224 * @param int $token_id Token id.1223 * @param mixed $order_total Order total. 1224 * @param int $token_id Token id. 1225 1225 * 1226 1226 * @return \WeArePlanet\Sdk\Model\Transaction 1227 * @throws Exception 1228 * If the transaction being created is not valid. 1227 * @throws Exception Exception. 1229 1228 */ 1230 1229 public function create_transaction_by_renewal_order( WC_Order $order, $order_total, $token_id ) { … … 1241 1240 1242 1241 $create_transaction = apply_filters( 'wc_weareplanet_subscription_create_transaction', $create_transaction, $order ); 1243 if (!$create_transaction->valid()) { 1244 throw new Exception("The transaction you are trying to create is not valid."); 1245 } 1246 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [ 1247 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true 1248 ]); 1242 if ( ! $create_transaction->valid() ) { 1243 throw new Exception( 'The transaction you are trying to create is not valid.' ); 1244 } 1245 WC_WeArePlanet_Helper::instance()->add_headers( 1246 $this->api_client, 1247 array( 1248 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true, 1249 ) 1250 ); 1249 1251 $transaction = $this->get_transaction_service()->create( $space_id, $create_transaction ); 1250 1252 $this->update_transaction_info( $transaction, $order ); … … 1255 1257 * Creates a transaction for the given order. 1256 1258 * 1257 * @param WC_Order $order Order.1259 * @param WC_Order $order Order. 1258 1260 * @param mixed $order_total Order total. 1259 * @param int $token_id Token id.1261 * @param int $token_id Token id. 1260 1262 * @param \WeArePlanet\Sdk\Model\Transaction $transaction Transaction. 1261 1263 * … … 1275 1277 $this->set_modified_order_line_items( $order, $order_total, $pending_transaction ); 1276 1278 $pending_transaction = apply_filters( 'wc_weareplanet_subscription_update_transaction', $pending_transaction, $order ); 1277 WC_WeArePlanet_Helper::instance()->add_headers( $this->api_client, [ 1278 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true 1279 ]); 1279 WC_WeArePlanet_Helper::instance()->add_headers( 1280 $this->api_client, 1281 array( 1282 WC_WeArePlanet_Helper::SUBSCRIPTION_TRANSACTION => true, 1283 ) 1284 ); 1280 1285 return $this->get_transaction_service()->update( $transaction->getLinkedSpaceId(), $pending_transaction ); 1281 1286 } catch ( \WeArePlanet\Sdk\VersioningException $e ) { … … 1289 1294 * Process transaction without user interaction. 1290 1295 * 1291 * @param mixed $space_id Space id.1296 * @param mixed $space_id Space id. 1292 1297 * @param mixed $transaction_id Transaction id. 1293 1298 * -
weareplanet/trunk/includes/service/class-wc-weareplanet-service-webhook.php
r3288388 r3740659 200 200 } 201 201 } 202 $this->enforce_signed_listeners(); 202 203 } 203 204 … … 219 220 * Create a webhook listener. 220 221 * 221 * @param WC_WeArePlanet_Webhook_Entity $entity entity.222 * @param int $space_id space id.222 * @param WC_WeArePlanet_Webhook_Entity $entity entity. 223 * @param int $space_id space id. 223 224 * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url. 224 225 * … … 241 242 * Returns the existing webhook listeners. 242 243 * 243 * @param int $space_id space id.244 * @param int $space_id space id. 244 245 * @param \WeArePlanet\Sdk\Model\WebhookUrl $webhook_url webhook url. 245 246 * … … 343 344 return $this->webhook_url_service; 344 345 } 346 347 /** 348 * Enforces payload signatures on webhook listeners. 349 * 350 * @throws \Exception Exception. 351 */ 352 public function enforce_signed_listeners() { 353 $space_id = get_option( WooCommerce_WeArePlanet::WEAREPLANET_CK_SPACE_ID ); 354 if ( empty( $space_id ) ) { 355 return; 356 } 357 $webhook_url = $this->get_webhook_url( $space_id ); 358 if ( null === $webhook_url ) { 359 return; 360 } 361 try { 362 $webhook_listeners = $this->get_webhook_listeners( $space_id, $webhook_url ); 363 } catch ( Exception $e ) { 364 WooCommerce_WeArePlanet::instance()->log( 365 'Could not load webhook listeners to enforce signing: ' . $e->getMessage(), 366 WC_Log_Levels::ERROR 367 ); 368 } 369 $webhook_service = $this->get_webhook_listener_service(); 370 foreach ( $webhook_listeners as $listener ) { 371 if ( $listener->getEnablePayloadSignatureAndState() ) { 372 continue; 373 } 374 try { 375 $update = new \WeArePlanet\Sdk\Model\WebhookListenerUpdate(); 376 $update->setId( $listener->getId() ); 377 $update->setVersion( $listener->getVersion() ); 378 $update->setEnablePayloadSignatureAndState( true ); 379 $webhook_service->update( $space_id, $update ); 380 } catch ( \Exception $e ) { 381 WooCommerce_WeArePlanet::instance()->log( 382 'Could not update webhook listeners to enforce signing: ' . $e->getMessage(), 383 WC_Log_Levels::ERROR 384 ); 385 } 386 } 387 } 345 388 } -
weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-delivery-indication-strategy.php
r3378673 r3740659 63 63 64 64 /** 65 * Meant to bridge code from deprecated processor.66 *67 * @param WC_Order $order The WooCommerce order linked to the delivery indication.68 * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object.69 * @param WC_WeArePlanet_Webhook_Request $request The webhook request.70 * @return void71 */72 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) {73 $this->process_order_related_inner( $order, $delivery_indication, $request, true );74 }75 76 /**77 65 * Processes the incoming webhook request pertaining to delivery indications. 78 66 * … … 95 83 * Additional processing on the order based on the state of the delivery indication. 96 84 * 97 * @param WC_Order $order The WooCommerce order linked to the delivery indication.85 * @param WC_Order $order The WooCommerce order linked to the delivery indication. 98 86 * @param \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication The delivery indication object. 99 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 100 * @param bool $legacy_mode legacy code used. 87 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 101 88 * @return void 102 89 */ 103 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {104 $entity_state = $ legacy_mode ? $delivery_indication->getState() : $request->get_state();90 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\DeliveryIndication $delivery_indication, WC_WeArePlanet_Webhook_Request $request ) { 91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\DeliveryIndicationState::MANUAL_CHECK_REQUIRED: -
weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-refund-strategy.php
r3378673 r3740659 62 62 63 63 /** 64 * Meant to bridge code from deprecated processor.65 *66 * @param WC_Order $order The WooCommerce order associated with the refund.67 * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object.68 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.69 * @return void70 */71 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) {72 $this->process_order_related_inner( $order, $refund, $request, true );73 }74 75 /**76 64 * Processes the incoming webhook request related to refunds. 77 65 * … … 97 85 * @param \WeArePlanet\Sdk\Model\Refund $refund The transaction refund object. 98 86 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 99 * @param bool $legacy_mode legacy code used.100 87 * @return void 101 88 */ 102 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {89 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\Refund $refund, WC_WeArePlanet_Webhook_Request $request ) { 103 90 /* @var \WeArePlanet\Sdk\Model\Refund $refund */ 104 $entity_state = $ legacy_mode ? $refund->getState() : $request->get_state();91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\RefundState::FAILED: -
weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-completion-strategy.php
r3378673 r3740659 63 63 64 64 /** 65 * Meant to bridge code from deprecated processor.66 *67 * @param WC_Order $order The WooCommerce order linked to the completion.68 * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object.69 * @param WC_WeArePlanet_Webhook_Request $request The webhook request.70 * @return void71 */72 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) {73 $this->process_order_related_inner( $order, $completion, $request, true );74 }75 76 /**77 65 * Processes the incoming webhook request pertaining to transaction completions. 78 66 * … … 98 86 * @param \WeArePlanet\Sdk\Model\TransactionCompletion $completion The transaction completion object. 99 87 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 100 * @param bool $legacy_mode legacy code used. 101 * @return void 102 */ 103 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request, $legacy_mode = false ) { 104 $entity_state = $legacy_mode ? $completion->getState() : $request->get_state(); 88 * @return void 89 */ 90 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionCompletion $completion, WC_WeArePlanet_Webhook_Request $request ) { 91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\TransactionCompletionState::FAILED: -
weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-invoice-strategy.php
r3378673 r3740659 63 63 64 64 /** 65 * Meant to bridge code from deprecated processor.66 *67 * @param WC_Order $order The WooCommerce order linked to the invoice.68 * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object.69 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.70 * @return void71 */72 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) {73 $this->process_order_related_inner( $order, $transaction_invoice, $request, true );74 }75 76 /**77 65 * Processes the incoming webhook request pertaining to transaction invoices. 78 66 * … … 95 83 * Additional processing on the order based on the state of the transaction invoice. 96 84 * 97 * @param WC_Order $order The WooCommerce order linked to the invoice.85 * @param WC_Order $order The WooCommerce order linked to the invoice. 98 86 * @param \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice The transaction invoice object. 99 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 100 * @param bool $legacy_mode legacy code used. 87 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 101 88 * @return void 102 89 */ 103 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {104 $entity_state = $ legacy_mode ? $transaction_invoice->getState() : $request->get_state();90 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionInvoice $transaction_invoice, WC_WeArePlanet_Webhook_Request $request ) { 91 $entity_state = $request->get_state(); 105 92 switch ( $entity_state ) { 106 93 case \WeArePlanet\Sdk\Model\TransactionInvoiceState::DERECOGNIZED: -
weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-strategy.php
r3598699 r3740659 38 38 39 39 /** 40 * Meant to bridge code from deprecated processor.41 *42 * @param WC_Order $order order.43 * @param mixed $transaction transaction.44 * @return mixed The result of the processing.45 */46 public function bridge_process_order_related_inner( WC_Order $order, $transaction ) {47 $this->process_order_related_inner( $order, $transaction, true );48 }49 50 /**51 40 * Process the webhook request. 52 41 * 53 * @param \WeArePlanet\Sdk\Model\Transaction $transaction The webhook request object.42 * @param WC_WeArePlanet_Webhook_Request $request The webhook request. 54 43 * @return mixed The result of the processing. 55 44 */ … … 58 47 $entity = $this->load_entity( $request ); 59 48 60 // retry orphaned transaction, fall back to merchant reference49 // Retry orphaned transaction, fall back to merchant reference. 61 50 if ( ( false === $order || ! $order->get_id() ) && $entity ) { 62 51 $merchant_ref = $entity->getMerchantReference(); … … 68 57 if ( false != $order && $order->get_id() ) { 69 58 $this->process_order_related_inner( $order, $entity ); 70 if ( $request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {59 if ( $request->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED ) { 71 60 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() ); 72 61 } … … 79 68 * @param WC_Order $order order. 80 69 * @param mixed $transaction transaction. 81 * @param bool $legacy_mode legacy code used.82 70 * @return void 83 71 * @throws Exception Exception. 84 72 */ 85 protected function process_order_related_inner( WC_Order $order, $transaction , $legacy_mode = false) {73 protected function process_order_related_inner( WC_Order $order, $transaction ) { 86 74 if ( strpos( $order->get_payment_method(), 'weareplanet' ) === false ) { 87 75 return; … … 108 96 $this->authorize( $transaction, $order ); 109 97 $this->fulfill( $transaction, $order ); 110 if ( $legacy_mode ) {111 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );112 }113 98 WC_WeArePlanet_Helper::set_virtual_zero_total_orders_to_complete( $order ); 114 99 WC_WeArePlanet_Helper::update_order_status_for_preorder_if_needed( $order ); … … 127 112 WC_WeArePlanet_Service_Transaction::instance()->update_transaction_info( $transaction, $order ); 128 113 } 129 130 if ( $legacy_mode ) {131 // This is edge case for deferred payment methods132 $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() );133 if ($transaction_info->get_state() === \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED) {134 do_action( 'weareplanet_transaction_authorized_send_email', $order->get_id() );135 }136 }137 114 } 138 115 … … 141 118 * 142 119 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 143 * @param WC_Order $order order.120 * @param WC_Order $order order. 144 121 * @return void 145 122 */ … … 162 139 * 163 140 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 164 * @param \WC_Order $order order.141 * @param \WC_Order $order order. 165 142 */ 166 143 protected function authorize( \WeArePlanet\Sdk\Model\Transaction $transaction, WC_Order $order ) { … … 181 158 * 182 159 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 183 * @param WC_Order $order order.160 * @param WC_Order $order order. 184 161 * @return void 185 162 */ … … 200 177 * 201 178 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 202 * @param WC_Order $order order.179 * @param WC_Order $order order. 203 180 * @return void 204 181 */ … … 217 194 * 218 195 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 219 * @param WC_Order $order order.196 * @param WC_Order $order order. 220 197 * @return void 221 198 */ … … 231 208 // Custom order statuses mapped. 232 209 apply_filters( 'weareplanet_wc_status_for_transaction', 'confirmed' ), 233 apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' ) 210 apply_filters( 'weareplanet_wc_status_for_transaction', 'failed' ), 234 211 ); 235 212 if ( in_array( $order->get_status( 'edit' ), $valid_order_statuses ) ) { … … 244 221 * 245 222 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 246 * @param WC_Order $order order.223 * @param WC_Order $order order. 247 224 * @return void 248 225 */ … … 274 251 * 275 252 * @param \WeArePlanet\Sdk\Model\Transaction $transaction transaction. 276 * @param WC_Order $order order.253 * @param WC_Order $order order. 277 254 * @return void 278 255 */ -
weareplanet/trunk/includes/webhook/strategies/class-wc-weareplanet-webhook-transaction-void-strategy.php
r3378673 r3740659 66 66 67 67 /** 68 * Meant to bridge code from deprecated processor.69 *70 * @param WC_Order $order The WooCommerce order associated with the void request.71 * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object.72 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object.73 * @return void74 */75 public function bridge_process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) {76 $this->process_order_related_inner( $order, $void, $request, true );77 }78 79 /**80 68 * Processes the incoming webhook request related to transaction voids. 81 69 * … … 101 89 * @param \WeArePlanet\Sdk\Model\TransactionVoid $void The transaction void object. 102 90 * @param WC_WeArePlanet_Webhook_Request $request The webhook request object. 103 * @param bool $legacy_mode legacy code used.104 91 * @return void 105 92 */ 106 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request , $legacy_mode = false) {107 $entity_state = $ legacy_mode ? $void->getState() : $request->get_state();93 protected function process_order_related_inner( WC_Order $order, \WeArePlanet\Sdk\Model\TransactionVoid $void, WC_WeArePlanet_Webhook_Request $request ) { 94 $entity_state = $request->get_state(); 108 95 switch ( $entity_state ) { 109 96 case \WeArePlanet\Sdk\Model\TransactionVoidState::FAILED: -
weareplanet/trunk/readme.txt
r3676036 r3740659 3 3 Tags: payment, WeArePlanet, e-commerce, invoice, psp 4 4 Requires at least: 6.0 5 Tested up to: 7. 06 Stable tag: 3.4. 85 Tested up to: 7.1.2 6 Stable tag: 3.4.9 7 7 License: Apache-2.0 8 8 License URI: http://www.apache.org/licenses/LICENSE-2.0 … … 22 22 23 23 Additional documentation for this plugin is available: 24 [here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4. 8/docs/en/documentation.html).24 [here](https://plugin-documentation.weareplanet.com/weareplanet/woocommerce/3.4.9/docs/en/documentation.html). 25 25 26 26 == Source code and build process == … … 204 204 == Changelog == 205 205 206 = 3.4.8 - September 1 2026 = 207 - [BugFix] Fixed missing assets 206 = 3.4.9 - October 7 2026 = 207 - [Feature] Tested against Wordpress 7.1.2 208 - [Bugfix] Fixed issue where translations for payment methods were incorrect 208 209 - [Tested Against] PHP 8.4.20 209 - [Tested Against] Wordpress 7 210 - [Tested Against] Woocommerce 11. 0.1211 - [Tested Against] PHP SDK 4.9. 1210 - [Tested Against] Wordpress 7.1.2 211 - [Tested Against] Woocommerce 11.2.0 212 - [Tested Against] PHP SDK 4.9.2 -
weareplanet/trunk/views/admin-notices/subscription-plugin-deactivate.php
r3433358 r3740659 19 19 ?> 20 20 <div class="error notice notice-error"> 21 <p>22 <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?>23 </p>21 <p> 22 <?php esc_html_e( 'WeArePlanet Subscription plugin has been deactivated because subscriptions are now handled directly by the WeArePlanet plugin. You can safely remove the old plugin', 'woo-weareplanet' ); ?> 23 </p> 24 24 </div> -
weareplanet/trunk/views/admin-settings/html-admin-page-order-statuses.php
r3463230 r3740659 25 25 <thead> 26 26 <tr> 27 <?php foreach ( $order_statuses_columns as $ status_key => $heading ) : ?>28 <th class="<?php echo esc_attr( $ status_key ); ?>"><?php echo esc_html( $heading ); ?></th>27 <?php foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) : ?> 28 <th class="<?php echo esc_attr( $weareplanet_status_key ); ?>"><?php echo esc_html( $weareplanet_heading ); ?></th> 29 29 <?php endforeach; ?> 30 30 <th /> … … 55 55 <article> 56 56 <form action="" method="post"> 57 <input type="hidden" name="key" value="{{{ data.key }}}" />57 <input type="hidden" name="key" value="{{{ data.key }}}" /> 58 58 <?php 59 foreach ( $order_statuses_columns as $ status_key => $heading ) {60 echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $ status_key ) . '">';61 switch ( $ status_key ) {59 foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) { 60 echo '<div class="weareplanet-order-statuses-modal-input wc-shipping-class-modal-input ' . esc_attr( $weareplanet_status_key ) . '">'; 61 switch ( $weareplanet_status_key ) { 62 62 case 'weareplanet-order-status-key': 63 63 ?> 64 64 <div class="view"> 65 <?php echo esc_html( $ heading ); ?> *65 <?php echo esc_html( $weareplanet_heading ); ?> * 66 66 </div> 67 67 <div class="edit"> … … 74 74 placeholder="<?php esc_attr_e( 'e.g. awaiting', 'woo-weareplanet' ); ?>" /> 75 75 </label> 76 <small id="charCount" style="color: gray;"></small>76 <small id="charCount" style="color: gray;"></small> 77 77 </div> 78 78 <div class="weareplanet-order-statuses-modal-help-text wc-shipping-class-modal-help-text"><?php esc_html_e( 'Give your custom status a name for easy identification', 'woo-weareplanet' ); ?></div> … … 102 102 <tr data-id="{{ data.key }}"> 103 103 <?php 104 foreach ( $order_statuses_columns as $ status_key => $heading ) {105 echo '<td class="' . esc_attr( $ status_key ) . '">';106 switch ( $ status_key ) {104 foreach ( $order_statuses_columns as $weareplanet_status_key => $weareplanet_heading ) { 105 echo '<td class="' . esc_attr( $weareplanet_status_key ) . '">'; 106 switch ( $weareplanet_status_key ) { 107 107 case 'weareplanet-order-status-key': 108 108 ?> -
weareplanet/trunk/weareplanet-sdk/composer.json
r3673687 r3740659 1 1 { 2 2 "name": "weareplanet/sdk", 3 "version": "4.9. 1",3 "version": "4.9.2", 4 4 "description": "WeArePlanet SDK for PHP", 5 5 "keywords": [ -
weareplanet/trunk/weareplanet-sdk/lib/ApiClient.php
r3673687 r3740659 49 49 */ 50 50 private $defaultHeaders = [ 51 'x-meta-sdk-version' => "4.9. 1",51 'x-meta-sdk-version' => "4.9.2", 52 52 'x-meta-sdk-language' => 'php', 53 53 'x-meta-sdk-provider' => "WeArePlanet", … … 59 59 * @var string 60 60 */ 61 private $userAgent = 'PHP-Client/4.9. 1/php';61 private $userAgent = 'PHP-Client/4.9.2/php'; 62 62 63 63 /** -
weareplanet/trunk/weareplanet-sdk/lib/Configuration.php
r3673687 r3740659 81 81 * @var string 82 82 */ 83 protected $userAgent = 'WeArePlanet\Sdk/4.9. 1/php';83 protected $userAgent = 'WeArePlanet\Sdk/4.9.2/php'; 84 84 85 85 /** … … 389 389 $report .= ' OS: ' . php_uname() . PHP_EOL; 390 390 $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; 391 $report .= ' OpenAPI Spec Version: 4.9. 1' . PHP_EOL;392 $report .= ' SDK Package Version: 4.9. 1' . PHP_EOL;391 $report .= ' OpenAPI Spec Version: 4.9.2' . PHP_EOL; 392 $report .= ' SDK Package Version: 4.9.2' . PHP_EOL; 393 393 $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; 394 394 -
weareplanet/trunk/weareplanet-sdk/lib/Model/AbstractWebhookListenerUpdate.php
r3673687 r3740659 49 49 */ 50 50 protected static $swaggerTypes = [ 51 'enable_payload_signature_and_state' => 'bool', 51 52 'entity_states' => 'string[]', 52 53 'name' => 'string', … … 61 62 */ 62 63 protected static $swaggerFormats = [ 64 'enable_payload_signature_and_state' => null, 63 65 'entity_states' => null, 64 66 'name' => null, … … 74 76 */ 75 77 protected static $attributeMap = [ 78 'enable_payload_signature_and_state' => 'enablePayloadSignatureAndState', 76 79 'entity_states' => 'entityStates', 77 80 'name' => 'name', … … 86 89 */ 87 90 protected static $setters = [ 91 'enable_payload_signature_and_state' => 'setEnablePayloadSignatureAndState', 88 92 'entity_states' => 'setEntityStates', 89 93 'name' => 'setName', … … 98 102 */ 99 103 protected static $getters = [ 104 'enable_payload_signature_and_state' => 'getEnablePayloadSignatureAndState', 100 105 'entity_states' => 'getEntityStates', 101 106 'name' => 'getName', … … 121 126 public function __construct(?array $data = null) 122 127 { 128 129 $this->container['enable_payload_signature_and_state'] = isset($data['enable_payload_signature_and_state']) ? $data['enable_payload_signature_and_state'] : null; 123 130 124 131 $this->container['entity_states'] = isset($data['entity_states']) ? $data['entity_states'] : null; -
weareplanet/trunk/weareplanet-sdk/test/ApiClientTest.php
r3673687 r3740659 145 145 146 146 // Check SDK default header values. 147 $this->assertEquals($headers['x-meta-sdk-version'], "4.9. 1");147 $this->assertEquals($headers['x-meta-sdk-version'], "4.9.2"); 148 148 $this->assertEquals($headers['x-meta-sdk-language'], 'php'); 149 149 $this->assertEquals($headers['x-meta-sdk-provider'], "WeArePlanet"); -
weareplanet/trunk/weareplanet.php
r3676036 r3740659 4 4 * Plugin URI: https://wordpress.org/plugins/woo-weareplanet 5 5 * Description: Process WooCommerce payments with WeArePlanet. 6 * Version: 3.4. 86 * Version: 3.4.9 7 7 * Author: Planet Merchant Services Ltd 8 8 * Author URI: https://www.weareplanet.com … … 16 16 * License: Apache-2.0 17 17 * License URI: http://www.apache.org/licenses/LICENSE-2.0 18 * 19 * @package WeArePlanet 18 20 */ 21 19 22 if ( ! defined( 'ABSPATH' ) ) { 20 23 exit(); // Exit if accessed directly. … … 43 46 const WEAREPLANET_CK_DISABLE_PENDING_EMAIL = 'wc_weareplanet_disable_pending_email'; 44 47 const WEAREPLANET_CK_ENABLE_CUSTOM_STATUS_MAPPING = 'wc_weareplanet_enable_custom_status_mapping'; 45 const WEAREPLANET_UPGRADE_VERSION = '3.1.1'; 46 const WC_MAXIMUM_VERSION = '11. 0.1';48 const WEAREPLANET_UPGRADE_VERSION = '3.1.1'; // Leave this number alone! It was a fix for a problem introduced at this version. 49 const WC_MAXIMUM_VERSION = '11.2.0'; 47 50 const REQUIRED_WC_SUBSCRIPTION_VERSION = '2.5'; 48 51 … … 52 55 * @var string 53 56 */ 54 private $version = '3.4. 8';57 private $version = '3.4.9'; 55 58 56 59 /** … … 89 92 } 90 93 94 /** 95 * Define constant if not already set. 96 */ 91 97 public function boot() { 92 98 $this->init(); 93 99 } 94 100 101 /** 102 * Initialize the plugin. 103 */ 95 104 private function init() { 96 105 $this->includes(); … … 159 168 array( 160 169 'WooCommerce_WeArePlanet', 161 'migrate_plugin_data_on_activation' 170 'migrate_plugin_data_on_activation', 162 171 ) 163 172 ); … … 393 402 */ 394 403 public static function get_installed_plugin_version( $plugin_slug ) { 395 if ( !function_exists( 'get_plugins' ) ) {404 if ( ! function_exists( 'get_plugins' ) ) { 396 405 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 397 406 } … … 400 409 foreach ( $all_plugins as $plugin_path => $plugin_info ) { 401 410 if ( strpos( $plugin_path, $plugin_slug ) !== false ) { 402 return $plugin_info[ 'Version'];411 return $plugin_info['Version']; 403 412 } 404 413 } … … 457 466 458 467 global $wpdb; 459 $options_to_migrate = [468 $options_to_migrate = array( 460 469 $old_option_prefix . WC_WeArePlanet_Migration::WEAREPLANET_CK_DB_VERSION, 461 470 $old_option_prefix . WC_WeArePlanet_Service_Manual_Task::WEAREPLANET_CONFIG_KEY, … … 472 481 $old_option_prefix . self::WEAREPLANET_CK_CHANGE_ORDER_STATUS, 473 482 $old_option_prefix . self::WC_MAXIMUM_VERSION, 474 ];483 ); 475 484 476 485 // If the old plugin options exist, perform the migration. … … 487 496 add_option( $new_option_name, $option_value ); 488 497 } 489 // Delete the old option. 490 //delete_option( $option_name );. 498 // Delete the old option: delete_option( $option_name );. 491 499 } 492 500 } … … 498 506 * 499 507 * @param object $upgrader_object The upgrader object. 500 * @param array $options The options array.508 * @param array $options The options array. 501 509 */ 502 510 public static function migrate_plugin_data_after_update( $upgrader_object, $options ) { … … 530 538 531 539 // WordPress.org will auto-load translations. No need to call load_plugin_textdomain(). 532 // $this->load_plugin_textdomain(); 533 add_action('plugins_loaded', function () { 534 if (class_exists('WC_Payment_Gateway')) { 535 require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php'; 536 add_filter( 537 'woocommerce_payment_gateways', 538 array( 539 WooCommerce_WeArePlanet::instance(), 540 'add_gateways', 541 ) 542 ); 543 } 544 }, 20); 540 // $this->load_plugin_textdomain();. 541 add_action( 542 'plugins_loaded', 543 function () { 544 if ( class_exists( 'WC_Payment_Gateway' ) ) { 545 require_once WC_WEAREPLANET_ABSPATH . 'includes/class-wc-weareplanet-zero-gateway.php'; 546 add_filter( 547 'woocommerce_payment_gateways', 548 array( 549 WooCommerce_WeArePlanet::instance(), 550 'add_gateways', 551 ) 552 ); 553 } 554 }, 555 20 556 ); 545 557 add_action( 546 558 'plugins_loaded', … … 603 615 add_filter( 604 616 'woocommerce_cart_needs_payment', 605 function ($value, $object) {617 function ( $value, $object ) { 606 618 return true; 607 }, 10, 2 619 }, 620 10, 621 2 608 622 ); 609 623 add_filter( 610 'woocommerce_order_needs_payment',611 function($value, $order) {624 'woocommerce_order_needs_payment', 625 function ( $value, $order ) { 612 626 $order_data = $order->get_data(); 613 if ( substr_count($order_data['payment_method'], "weareplanet")) {627 if ( substr_count( $order_data['payment_method'], 'weareplanet' ) ) { 614 628 // If the order is using our payment method, we want to process it 615 629 // even if the value of the transaction is 0, which woocommerce by default 616 630 // process it without payment gateway. 617 631 $transaction_info = WC_WeArePlanet_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); 618 if ( in_array( 619 $transaction_info->get_state(), 620 array( 621 \WeArePlanet\Sdk\Model\TransactionState::FULFILL, 622 \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED, 623 \WeArePlanet\Sdk\Model\TransactionState::COMPLETED, 624 \WeArePlanet\Sdk\Model\TransactionState::FAILED, 625 \WeArePlanet\Sdk\Model\TransactionState::DECLINE, 626 ), 627 true 628 ) ) { 632 if ( 633 in_array( 634 $transaction_info->get_state(), 635 array( 636 \WeArePlanet\Sdk\Model\TransactionState::FULFILL, 637 \WeArePlanet\Sdk\Model\TransactionState::AUTHORIZED, 638 \WeArePlanet\Sdk\Model\TransactionState::COMPLETED, 639 \WeArePlanet\Sdk\Model\TransactionState::FAILED, 640 \WeArePlanet\Sdk\Model\TransactionState::DECLINE, 641 ), 642 true 643 ) 644 ) { 629 645 return false; 630 646 } … … 632 648 } 633 649 return $value; 634 }, 10, 2 650 }, 651 10, 652 2 635 653 ); 636 654 add_action( … … 772 790 ); 773 791 774 add_filter('the_content', function($content) { 775 if ( is_checkout() && ! is_order_received_page() ) { 776 // When in checkout, we inject the list of payment methods in the HTML. 777 // The goal here is to speed up the process of registering the payment methods. 778 $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods(); 779 $json_data = json_encode( $payment_methods ); 780 $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>'; 781 } 782 783 return $content; 784 }); 792 add_filter( 793 'the_content', 794 function ( $content ) { 795 if ( is_checkout() && ! is_order_received_page() ) { 796 // When in checkout, we inject the list of payment methods in the HTML. 797 // The goal here is to speed up the process of registering the payment methods. 798 $payment_methods = WC_WeArePlanet_Blocks_Support::get_payment_methods(); 799 $json_data = json_encode( $payment_methods ); 800 $content .= '<div id="weareplanet-payment-methods" data-json="' . esc_attr( $json_data ) . '"></div>'; 801 } 802 803 return $content; 804 } 805 ); 785 806 } 786 807 … … 806 827 * @return bool 807 828 */ 808 public static function is_subscriptions_compatible(): bool {829 public static function is_subscriptions_compatible(): bool { 809 830 $plugin_name = 'woocommerce-subscriptions.php'; 810 831 $woocommerce_subscriptions_directory = self::find_plugin_path( $plugin_name ); … … 825 846 * Looks for legacy subscription plugin's directory. 826 847 * 848 * @param string $plugin_name The plugin file name to search for. 827 849 * @return string|null 828 850 */ … … 867 889 } 868 890 869 /**870 * Register order statuses.871 *872 * @return void873 */874 public function register_order_statuses() {875 $common_args = array(876 'public' => true,877 'exclude_from_search' => false,878 'show_in_admin_all_list' => true,879 'show_in_admin_status_list' => true,880 );881 882 register_post_status(883 'wc-wearep-redirected',884 array_merge(891 /** 892 * Register order statuses. 893 * 894 * @return void 895 */ 896 public function register_order_statuses() { 897 $common_args = array( 898 'public' => true, 899 'exclude_from_search' => false, 900 'show_in_admin_all_list' => true, 901 'show_in_admin_status_list' => true, 902 ); 903 904 register_post_status( 905 'wc-wearep-redirected', 906 array_merge( 885 907 $common_args, 886 908 array( … … 918 940 * Add order statuses. 919 941 * 920 * @param mixed $order_statuses order statuses.921 * @return mixed922 */923 public function add_order_statuses( $order_statuses ) {924 $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' );925 $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' );926 $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' );927 928 return $order_statuses;942 * @param mixed $order_statuses order statuses. 943 * @return mixed 944 */ 945 public function add_order_statuses( $order_statuses ) { 946 $order_statuses['wc-wearep-redirected'] = _x( 'Redirected', 'Order status', 'woo-weareplanet' ); 947 $order_statuses['wc-wearep-waiting'] = _x( 'Waiting', 'Order status', 'woo-weareplanet' ); 948 $order_statuses['wc-wearep-manual'] = _x( 'Manual Decision', 'Order status', 'woo-weareplanet' ); 949 950 return $order_statuses; 929 951 } 930 952 … … 936 958 * @return mixed 937 959 */ 938 public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore939 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) {940 $statuses[] = 'wearep-redirected';941 }942 943 return $statuses;944 }960 public function valid_order_statuses_for_payment( $statuses, $order = null ) { //phpcs:ignore 961 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) { 962 $statuses[] = 'wearep-redirected'; 963 } 964 965 return $statuses; 966 } 945 967 946 968 /** … … 964 986 } 965 987 966 // Sanitize input properly.967 $changes = sanitize_text_field( wp_unslash( $_POST['changes'] ));988 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- $_POST['changes'] array is unslashed with wp_unslash(). We sanitize each field individually with array_map( 'sanitize_text_field' ) and sanitize_key() below. 989 $changes = wp_unslash( $_POST['changes'] ); 968 990 969 991 // Get the first key inside the 'changes' array. 970 992 $first_key = key( $changes ); 971 $data = $_POST['changes'][$first_key]; 993 if ( ! isset( $changes[ $first_key ] ) || ! is_array( $changes[ $first_key ] ) ) { 994 wp_send_json_error( 'invalid_data' ); 995 wp_die(); 996 } 997 $raw_data = $changes[ $first_key ]; 998 $data = array_map( 'sanitize_text_field', $raw_data ); 999 $first_key = sanitize_key( $first_key ); 972 1000 973 1001 if ( isset( $data['key'] ) ) { 974 $label = str_replace( ['-', '_'], ' ', sanitize_text_field( $data['key'] ) );1002 $label = str_replace( array( '-', '_' ), ' ', sanitize_text_field( $data['key'] ) ); 975 1003 976 1004 // Normalize the key by replacing spaces and dashes with underscores. 977 $sanitized_key_underscore = str_replace( [' ', '-'], '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key );978 $sanitized_key_hyphen = str_replace( [' ', '_'], '-', $first_key );1005 $sanitized_key_underscore = str_replace( array( '-', '_' ), '_', WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . $first_key ); 1006 $sanitized_key_hyphen = str_replace( array( ' ', '_' ), '-', $first_key ); 979 1007 980 1008 // Construct the full option name with the required prefix. … … 984 1012 update_option( $custom_order_name, $custom_order_value ); 985 1013 986 register_post_status( $custom_order_value, array( 987 'label' => $label, 988 'public' => true, 989 'show_in_admin_status_list' => true, 990 'show_in_admin_all_list' => true, 991 'exclude_from_search' => false, 992 'label_count' => array( 993 'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 994 'plural' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 1014 wp_cache_delete( 'weareplanet_custom_order_statuses', 'weareplanet' ); 1015 1016 register_post_status( 1017 $custom_order_value, 1018 array( 1019 'label' => $label, 1020 'public' => true, 1021 'show_in_admin_status_list' => true, 1022 'show_in_admin_all_list' => true, 1023 'exclude_from_search' => false, 1024 'label_count' => array( 1025 'singular' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 1026 'plural' => sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 1027 ) 995 1028 ) 996 ) );1029 ); 997 1030 998 1031 // Send a success response with the saved order status details. 999 wp_send_json_success([ 1000 'message' => 'Success', 1001 'order_status' => [ 1002 'key' => $custom_order_value, // The full key with the prefix. 1003 'label' => ucfirst( $label ), // As received from the form data. 1004 'type' => __( 'custom' , 'woo-weareplanet' ) 1005 ] 1006 ]); 1032 wp_send_json_success( 1033 array( 1034 'message' => 'Success', 1035 'order_status' => array( 1036 'key' => $custom_order_value, // The full key with the prefix. 1037 'label' => ucfirst( $label ), // As received from the form data. 1038 'type' => __( 'custom', 'woo-weareplanet' ), 1039 ), 1040 ) 1041 ); 1007 1042 } else { 1008 1043 wp_send_json_error( 'invalid_data' ); … … 1033 1068 1034 1069 $sanitized_key = sanitize_text_field( wp_unslash( $_POST['key'] ) ); 1035 1036 // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_". 1037 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%'; 1038 $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1070 $cache_group = 'weareplanet'; 1071 1072 $is_used_cache_key = 'weareplanet_status_in_use_' . md5( $sanitized_key ); 1073 $is_used = wp_cache_get( $is_used_cache_key, $cache_group ); 1074 1075 if ( $is_used === false ) { 1076 // Check if this order status is being used in wp_options with key prefix "weareplanet_order_status_mapping_". 1077 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_ORDER_STATUS_MAPPING_PREFIX . '%'; 1078 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 1079 $is_used = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1080 wp_cache_set( $is_used_cache_key, $is_used, $cache_group, HOUR_IN_SECONDS ); 1081 } 1039 1082 1040 1083 if ( $is_used > 0 ) { 1041 1084 // The status is in use, so do not delete it. 1042 wp_send_json_error( ['message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )], 400 ); 1043 } 1044 1045 // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_". 1046 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; 1047 $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1085 wp_send_json_error( 1086 array( 1087 'message' => __( 'Cannot delete: this status is currently in use.', 'woo-weareplanet' ), 1088 'key' => ucfirst( $sanitized_key ), 1089 ), 1090 400 1091 ); 1092 } 1093 1094 $option_name_cache_key = 'weareplanet_status_option_name_' . md5( $sanitized_key ); 1095 $custom_order_status_name = wp_cache_get( $option_name_cache_key, $cache_group ); 1096 1097 if ( $custom_order_status_name === false ) { 1098 // Get the custom order status in wp_options with key prefix "weareplanet_order_status_mapping_". 1099 $like_pattern = WC_WeArePlanet_Order_Status_Adapter::WEAREPLANET_CUSTOM_ORDER_STATUS_PREFIX . '%'; 1100 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 1101 $custom_order_status_name = $wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value = %s", $like_pattern, $sanitized_key ) ); 1102 wp_cache_set( $option_name_cache_key, $custom_order_status_name, $cache_group, HOUR_IN_SECONDS ); 1103 } 1048 1104 1049 1105 // Remove from wp_options. 1050 1106 delete_option( $custom_order_status_name ); 1051 1107 1108 wp_cache_delete( $is_used_cache_key, $cache_group ); 1109 wp_cache_delete( $option_name_cache_key, $cache_group ); 1110 wp_cache_delete( 'weareplanet_custom_order_statuses', $cache_group ); 1111 1052 1112 // Return success response. 1053 wp_send_json_success( ['message' => __( 'Deleted successfully', 'woo-weareplanet' ), 'key' => ucfirst( $sanitized_key )] ); 1113 wp_send_json_success( 1114 array( 1115 'message' => __( 'Deleted successfully', 'woo-weareplanet' ), 1116 'key' => ucfirst( $sanitized_key ), 1117 ) 1118 ); 1054 1119 } 1055 1120 … … 1060 1125 */ 1061 1126 public function set_device_id_cookie() { 1062 if (!headers_sent()) {1127 if ( ! headers_sent() ) { 1063 1128 $value = WC_WeArePlanet_Unique_Id::get_uuid(); 1064 1129 if ( isset( $_COOKIE['wc_weareplanet_device_id'] ) && ! empty( $_COOKIE['wc_weareplanet_device_id'] ) ) { … … 1122 1187 * @return false|mixed 1123 1188 */ 1124 public function order_editable_check( $allowed, WC_Order $order = null ) {1189 public function order_editable_check( $allowed, ?WC_Order $order = null ) { 1125 1190 if ( is_null( $order ) ) { 1126 1191 return $allowed; … … 1139 1204 * @return mixed 1140 1205 */ 1141 public function valid_order_status_for_completion( $statuses, WC_Order $order = null ) { //phpcs:ignore1206 public function valid_order_status_for_completion( $statuses, ?WC_Order $order = null ) { //phpcs:ignore 1142 1207 if ( WC_WeArePlanet_Helper::is_custom_status_mapping_enabled() ) { 1143 1208 $statuses[] = 'wearep-waiting'; … … 1192 1257 foreach ( $method_configurations as $configuration ) { 1193 1258 $gateway = new WC_WeArePlanet_Gateway( $configuration ); 1194 $methods[] = apply_filters( 'wc_weareplanet_enhance_gateway', $gateway);1259 $methods[] = apply_filters( 'wc_weareplanet_enhance_gateway', $gateway ); 1195 1260 } 1196 1261 } catch ( \WeArePlanet\Sdk\ApiException $e ) { … … 1352 1417 */ 1353 1418 public function register_checkout_error_msg() { 1354 if ( ! isset( WC()->session ) ) return false; 1419 if ( ! isset( WC()->session ) ) { 1420 return false; 1421 } 1355 1422 $msg = WC()->session->get( 'weareplanet_failure_message', null ); 1356 1423 if ( ! empty( $msg ) ) { … … 1380 1447 */ 1381 1448 protected function define( $name, $value ) { 1449 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound -- $name is a local, not a global parameter 1382 1450 if ( ! defined( $name ) ) { 1383 1451 define( $name, $value ); 1384 1452 } 1453 // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.VariableConstantNameFound 1385 1454 } 1386 1455 … … 1588 1657 } 1589 1658 1590 add_action( 'woocommerce_loaded', function () { 1591 WooCommerce_WeArePlanet::instance()->boot(); 1592 add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' ); 1593 }); 1659 add_action( 1660 'woocommerce_loaded', 1661 function () { 1662 WooCommerce_WeArePlanet::instance()->boot(); 1663 add_action( 'woocommerce_blocks_loaded', 'WC_WeArePlanet_Blocks_Support' ); 1664 } 1665 ); 1594 1666 1595 1667 function WC_WeArePlanet_Blocks_Support() { //phpcs:ignore
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)