PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Integration/WooCommerce/WooCommerceHandler.php +37 -12 2.10.03.3.1 View file →
@@ -6,12 +6,17 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\WooCommerce;
9 9
10 -use WP_Error;
11 -use WC_Data_Store;
10 +if (!defined('ABSPATH')) {
11 + exit;
12 +}
13 +
12 14 use BitCode\BitForm\Core\Integration\IntegrationHandler;
13 15 use BitCode\BitForm\Core\Util\ApiResponse as UtilApiResponse;
16 +use BitCode\BitForm\GlobalHelper;
17 +use WC_Data_Store;
18 +use WP_Error;
14 19
15 20 /**
16 21 * Provide functionality for ZohoCrm integration
17 22 */
@@ -47,9 +52,9 @@
47 52 * @return JSON zoho crm api response and status
48 53 */
49 54 public static function authorizeWC()
50 55 {
51 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
56 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
52 57 include_once ABSPATH . 'wp-admin/includes/plugin.php';
53 58 if (is_plugin_active('woocommerce/woocommerce.php')) {
54 59 wp_send_json_success(true, 200);
55 60 }
@@ -117,12 +122,19 @@
117 122 */
118 123 public static function refreshFieldsAjaxHelper()
119 124 {
120 125 $required = null;
121 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
122 - $inputJSON = file_get_contents('php://input');
123 - $queryParams = json_decode($inputJSON);
126 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
127 + GlobalHelper::requirePostMethod();
124 128
129 + try {
130 + $queryParams = GlobalHelper::formatRequestData();
131 + } catch (\InvalidArgumentException $e) {
132 + wp_send_json_error($e->getMessage(), 400);
133 + }
134 +
135 + $uploadFields = [];
136 +
125 137 if (
126 138 empty($queryParams->module)
127 139 ) {
128 140 wp_send_json_error(
@@ -437,9 +449,11 @@
437 449 $required = ['user_login', 'user_email'];
438 450 }
439 451
440 452 uksort($fields, 'strnatcasecmp');
441 - $uploadFields = !empty($uploadFields) && is_array($uploadFields) ? uksort($uploadFields, 'strnatcasecmp') : $uploadFields;
453 + // $uploadFields = !empty($uploadFields) && is_array($uploadFields) ? uksort($uploadFields, 'strnatcasecmp') : $uploadFields;
454 + uksort($uploadFields, 'strnatcasecmp');
455 +
442 456 $fields = array_merge($fields, $metabox['meta_fields']);
443 457
444 458 $response = [
445 459 'fields' => $fields,
@@ -458,14 +472,19 @@
458 472 );
459 473 }
460 474 }
461 475
462 - public function searchProjectsAjaxHelper()
476 + public static function searchProjectsAjaxHelper()
463 477 {
464 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
465 - $inputJSON = file_get_contents('php://input');
466 - $queryParams = json_decode($inputJSON);
478 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
479 + GlobalHelper::requirePostMethod();
467 480
481 + try {
482 + $queryParams = GlobalHelper::formatRequestData();
483 + } catch (\InvalidArgumentException $e) {
484 + wp_send_json_error($e->getMessage(), 400);
485 + }
486 +
468 487 include_once dirname(WC_PLUGIN_FILE) . '/includes/class-wc-product-functions.php';
469 488 $data_store = WC_Data_Store::load('product');
470 489 $search_results = $data_store->search_products($queryParams->searchTxt);
471 490 $products = [];
@@ -498,14 +517,20 @@
498 517 $module = $integrationDetails->module;
499 518 $fieldMap = $integrationDetails->field_map;
500 519 $uploadFieldMap = $integrationDetails->upload_field_map;
501 520 $required = $integrationDetails->default->fields->{$module}->required;
521 +
522 + $entryDetails = [
523 + 'formId' => $this->_formID,
524 + 'entryId' => $entryID,
525 + 'fieldValues' => $fieldValues
526 + ];
502 527 if (
503 528 empty($module)
504 529 || empty($fieldMap)
505 530 ) {
506 531 $error = new WP_Error('REQ_FIELD_EMPTY', __('module and field map are required for woocommerce', 'bit-form'));
507 - $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error);
532 + $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error, $entryDetails);
508 533 return $error;
509 534 }
510 535
511 536 $recordApiHelper = new RecordApiHelper($this->_integrationID, $logID);