Changeset 3375637
- Timestamp:
- 10/09/2025 10:06:32 AM (6 months ago)
- Location:
- connect-ecommerce
- Files:
-
- 18 edited
- 1 copied
-
tags/3.1.6 (copied) (copied from connect-ecommerce/trunk)
-
tags/3.1.6/composer.json (modified) (1 diff)
-
tags/3.1.6/connect-ecommerce.php (modified) (3 diffs)
-
tags/3.1.6/includes/Admin/Orders.php (modified) (1 diff)
-
tags/3.1.6/includes/Admin/Settings.php (modified) (11 diffs)
-
tags/3.1.6/includes/Helpers/ORDER.php (modified) (3 diffs)
-
tags/3.1.6/includes/Helpers/PROD.php (modified) (17 diffs)
-
tags/3.1.6/includes/assets/admin.css (modified) (1 diff)
-
tags/3.1.6/readme.txt (modified) (3 diffs)
-
tags/3.1.6/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/composer.json (modified) (1 diff)
-
trunk/connect-ecommerce.php (modified) (3 diffs)
-
trunk/includes/Admin/Orders.php (modified) (1 diff)
-
trunk/includes/Admin/Settings.php (modified) (11 diffs)
-
trunk/includes/Helpers/ORDER.php (modified) (3 diffs)
-
trunk/includes/Helpers/PROD.php (modified) (17 diffs)
-
trunk/includes/assets/admin.css (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
connect-ecommerce/tags/3.1.6/composer.json
r3362630 r3375637 42 42 "prepare-behat-tests": "install-package-tests", 43 43 "test": "phpunit", 44 "test-debug": "XDEBUG_MODE=debug XDEBUG_TRIGGER=1 phpunit", 44 45 "test-install": "bash bin/install-wp-tests.sh wordpress_test root 'root' 127.0.0.1 latest" 45 46 }, -
connect-ecommerce/tags/3.1.6/connect-ecommerce.php
r3362630 r3375637 6 6 * Author: Closetechnology 7 7 * Author URI: https://close.technology/ 8 * Version: 3.1. 58 * Version: 3.1.6 9 9 * Requires PHP: 7.4 10 10 * Requires at least: 6.3 … … 14 14 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 15 15 * 16 * Prefix: conecom_ 17 * 16 18 * @package WordPress 17 19 */ … … 19 21 defined( 'ABSPATH' ) || exit; 20 22 21 define( 'CONECOM_VERSION', '3.1. 5' );23 define( 'CONECOM_VERSION', '3.1.6' ); 22 24 define( 'CONECOM_FILE', __FILE__ ); 23 25 define( 'CONECOM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
connect-ecommerce/tags/3.1.6/includes/Admin/Orders.php
r3362630 r3375637 66 66 return; 67 67 } 68 $this->options = $options[ $connector ]; 69 $this->settings = get_option( 'connect_ecommerce' )[ $connector ] ?? array(); 70 $apiname = 'Connect_Ecommerce_' . $this->options['name']; 71 $this->connapi_erp = new $apiname( $options ); 72 $ecstatus = isset( $this->settings['ecstatus'] ) ? $this->settings['ecstatus'] : $this->options['order_only_order_completed']; 73 $this->meta_key_order = '_' . $this->options['slug'] . '_invoice_id'; 68 $this->options = $options[ $connector ]; 69 $this->settings = get_option( 'connect_ecommerce' )[ $connector ] ?? array(); 70 $this->settings['prod_mergevars'] = get_option( 'connect_ecommerce_prod_mergevars' )['prod_mergevars'] ?? array(); 71 $apiname = 'Connect_Ecommerce_' . $this->options['name']; 72 $this->connapi_erp = new $apiname( $options ); 73 $ecstatus = isset( $this->settings['ecstatus'] ) ? $this->settings['ecstatus'] : $this->options['order_only_order_completed']; 74 $this->meta_key_order = '_' . $this->options['slug'] . '_invoice_id'; 74 75 75 76 add_action( 'wp_ajax_connect_ecommerce_sync_orders', array( $this, 'sync_orders' ) ); -
connect-ecommerce/tags/3.1.6/includes/Admin/Settings.php
r3362630 r3375637 705 705 add_settings_section( 706 706 'connect_ecommerce_prod_mergevars_section', 707 __( 'Merge variables from product attributes to custom fields', 'connect-ecommerce' ),707 __( 'Merge variables from ERP to WooCommerce', 'connect-ecommerce' ), 708 708 array( $this, 'section_info_prod_mergevars' ), 709 709 'connect_ecommerce_prod_mergevars' … … 712 712 add_settings_field( 713 713 'wcpimh_prod_mergevars', 714 __( 'Merge fields with product', 'connect-ecommerce' ),714 __( 'Merge fields', 'connect-ecommerce' ), 715 715 array( $this, 'prod_mergevars_callback' ), 716 716 'connect_ecommerce_prod_mergevars', … … 928 928 $admin_settings = [ 929 929 $connector => [ 930 'api' => '',931 'idcentre' => '',932 'url' => '',933 'username' => '',934 'password' => '',935 'company' => '',936 'company_id' => '',937 'domain' => '',938 'dbname' => '',939 'stock' => 'no',940 'prodst' => 'draft',941 'virtual' => 'no',942 'backorders' => 'no',943 'catsep' => '',944 'catattr' => '',945 'filter' => '',930 'api' => '', 931 'idcentre' => '', 932 'url' => '', 933 'username' => '', 934 'password' => '', 935 'company' => '', 936 'company_id' => '', 937 'domain' => '', 938 'dbname' => '', 939 'stock' => 'no', 940 'prodst' => 'draft', 941 'virtual' => 'no', 942 'backorders' => 'no', 943 'catsep' => '', 944 'catattr' => '', 945 'filter' => '', 946 946 'pricesale_discount' => '', 947 'filter_sku' => '',948 'tax_option' => 'no',949 'rates' => 'default',950 'catnp' => 'yes',951 'doctype' => 'invoice',952 'cleanchars' => '',953 'approve_document' => 'no',954 'series' => '',955 'freeorder' => 'no',956 'ecstatus' => 'all',957 'order_tags' => '',958 'design_id' => '',959 'sync' => 'no',960 'sync_num' => 5,961 'sync_email' => 'yes',962 'prod_weight_eq' => '',963 'debug_log' => 'no',947 'filter_sku' => '', 948 'tax_option' => 'no', 949 'rates' => 'default', 950 'catnp' => 'yes', 951 'doctype' => 'invoice', 952 'cleanchars' => '', 953 'approve_document' => 'no', 954 'series' => '', 955 'freeorder' => 'no', 956 'ecstatus' => 'all', 957 'order_tags' => '', 958 'design_id' => '', 959 'sync' => 'no', 960 'sync_num' => 5, 961 'sync_email' => 'yes', 962 'prod_weight_eq' => '', 963 'debug_log' => 'no', 964 964 ], 965 965 ]; … … 1255 1255 } 1256 1256 printf( 1257 '<input class="regular-text" type="text" name="connect_ecommerce[<?php echo esc_html( $this->connector ); ?>][catsep]" id="wcpimh_catsep" value="%s" %s>', 1257 '<input class="regular-text" type="text" name="connect_ecommerce[%s][catsep]" id="wcpimh_catsep" value="%s" %s>', 1258 esc_html( $this->connector ), 1258 1259 isset( $this->settings['catsep'] ) ? esc_attr( $this->settings['catsep'] ) : '', 1259 1260 ! empty( $prod_category_fixed ) ? ' readonly' : '' … … 1435 1436 */ 1436 1437 public function doctype_callback() { 1438 $documents_type = array( 1439 'nosync' => __( 'Not sync', 'connect-ecommerce' ), 1440 'smart' => __( 'Smart', 'connect-ecommerce' ), 1441 'invoice' => __( 'Invoice', 'connect-ecommerce' ), 1442 'salesreceipt' => __( 'Sales receipt', 'connect-ecommerce' ), 1443 'salesorder' => __( 'Sales order', 'connect-ecommerce' ), 1444 'waybill' => __( 'Waybill', 'connect-ecommerce' ), 1445 ); 1437 1446 $doctype = isset( $this->settings['doctype'] ) ? $this->settings['doctype'] : 'invoice'; 1438 1447 ?> 1439 1448 <select name="connect_ecommerce[<?php echo esc_html( $this->connector ); ?>][doctype]" id="wcpimh_doctype"> 1440 <option value="nosync" <?php selected( $doctype, 'nosync' ); ?>><?php esc_html_e( 'Not sync', 'connect-ecommerce' ); ?></option> <option value="invoice" <?php selected( $doctype, 'invoice' ); ?>><?php esc_html_e( 'Invoice', 'connect-ecommerce' ); ?></option> <option value="salesreceipt" <?php selected( $doctype, 'salesreceipt' ); ?>><?php esc_html_e( 'Sales receipt', 'connect-ecommerce' ); ?></option> <option value="salesorder" <?php selected( $doctype, 'salesorder' ); ?>><?php esc_html_e( 'Sales order', 'connect-ecommerce' ); ?></option> <option value="waybill" <?php selected( $doctype, 'waybill' ); ?>><?php esc_html_e( 'Waybill', 'connect-ecommerce' ); ?></option> 1449 <?php 1450 foreach ( $documents_type as $value => $label ) { 1451 echo '<option value="' . esc_html( $value ) . '" '; 1452 selected( $value, $doctype ); 1453 echo '>' . esc_html( $label ) . '</option>'; 1454 } 1455 ?> 1441 1456 </select> 1442 1457 <?php … … 1634 1649 */ 1635 1650 public function prod_mergevars_callback() { 1636 $product_fields = PROD::get_all_product_fields(); 1637 $custom_fields = PROD::get_all_custom_fields(); 1638 $custom_taxonomies = TAX::get_all_custom_taxonomies(); 1639 $product_cat_terms = TAX::get_terms_product_cat(); 1640 $attribute_fields = $this->connapi_erp->get_product_attributes(); 1651 $product_fields = PROD::get_all_product_fields(); 1652 $custom_fields = PROD::get_all_custom_fields(); 1653 $custom_taxonomies = TAX::get_all_custom_taxonomies(); 1654 $product_cat_terms = TAX::get_terms_product_cat(); 1655 $attribute_fields = $this->connapi_erp->get_product_attributes(); 1656 $payment_methods_api = method_exists( $this->connapi_erp, 'get_payment_methods' ) ? $this->connapi_erp->get_payment_methods() : array(); 1657 $payment_methods = WC()->payment_gateways()->get_available_payment_gateways(); 1641 1658 1642 1659 $settings_mergevars = ! empty( $this->settings_prod_mergevars['prod_mergevars'] ) ? $this->settings_prod_mergevars['prod_mergevars'] : array(); … … 1660 1677 $size = ! empty( $settings_mergevars ) ? count( $settings_mergevars ) : 0; 1661 1678 for ( $idx = 0, $size; $idx <= $size; ++$idx ) { 1662 $attrprod = isset( $saved_attr[ $idx ]['attrprod'] ) ? $saved_attr[ $idx ]['attrprod'] : ''; 1679 $attrprod = isset( $saved_attr[ $idx ]['attrprod'] ) ? $saved_attr[ $idx ]['attrprod'] : ''; 1680 $attrprod_label = ''; 1663 1681 ?> 1664 1682 <div class="product-mergevars repeating" style="border: 1px solid #ccc; padding: 10px; margin-bottom: 10px;"> … … 1668 1686 <?php 1669 1687 foreach ( $attribute_fields as $attribute ) { 1688 if ( empty( $attribute['elements'] ) ) { 1689 continue; 1690 } 1670 1691 ?> 1671 1692 <optgroup label="<?php echo esc_html( $attribute['name'] ); ?>"> … … 1676 1697 selected( $option_id, $attrprod ); 1677 1698 echo '>' . esc_html( $value ) . '</option>'; 1699 1700 if ( $option_id === $attrprod ) { 1701 $attrprod_label = $attribute['name']; 1702 } 1678 1703 } 1679 1704 ?> … … 1682 1707 } 1683 1708 ?> 1709 <?php if ( ! empty( $payment_methods_api ) ) { ?> 1710 <optgroup label="<?php esc_html_e( 'Payment Methods', 'connect-ecommerce' ); ?>"> 1711 <?php 1712 foreach ( $payment_methods_api as $key => $value ) { 1713 echo '<option value="' . esc_html( $key ) . '" '; 1714 selected( $key, $attrprod ); 1715 echo '>' . esc_html( $value ) . '</option>'; 1716 1717 if ( $key === $attrprod ) { 1718 $attrprod_label = __( 'Payment Method', 'connect-ecommerce' ); 1719 } 1720 } 1721 ?> 1722 </optgroup> 1723 <?php } ?> 1684 1724 </select> 1685 1725 </div> 1726 <span class="attrprod-label"> 1727 <?php 1728 if ( ! empty( $attrprod_label ) ) { 1729 echo esc_html( $attrprod_label ); 1730 } 1731 ?> 1732 </span> 1686 1733 <span class="dashicons dashicons-arrow-right-alt2"></span> 1687 1734 <div class="save-item"> 1688 <?php 1735 <?php 1689 1736 $saved_custom_field = isset( $saved_attr[ $idx ]['custom_field'] ) ? $saved_attr[ $idx ]['custom_field'] : ''; 1690 1737 $all_fields = array_merge( $product_fields, $product_cat_terms, $custom_taxonomies, $custom_fields ); … … 1733 1780 ?> 1734 1781 </optgroup> 1782 <?php if ( ! empty( $payment_methods_api ) ) { ?> 1783 <optgroup label="<?php esc_html_e( 'Payment Methods', 'connect-ecommerce' ); ?>"> 1784 <?php 1785 foreach ( $payment_methods as $method ) { 1786 $key = 'cf|' . $method->id; 1787 ?> 1788 <option value="<?php echo esc_html( $key ); ?>" <?php selected( $key, $saved_custom_field ); ?>><?php echo esc_html( $method->title ); ?></option> 1789 <?php } ?> 1790 </optgroup> 1791 <?php } ?> 1735 1792 </select> 1736 1793 </div> -
connect-ecommerce/tags/3.1.6/includes/Helpers/ORDER.php
r3362630 r3375637 121 121 $contact_name = $order->get_billing_company(); 122 122 } 123 $first_name = $order->get_billing_first_name(); 124 $last_name = $order->get_billing_last_name(); 123 $first_name = $order->get_billing_first_name(); 124 $last_name = $order->get_billing_last_name(); 125 $billing_company = $order->get_billing_company(); 126 $billing_address = $order->get_billing_address_1() . ',' . $order->get_billing_address_2(); 127 $billing_city = $order->get_billing_city(); 128 $billing_postcode = $order->get_billing_postcode(); 129 $billing_state_code = $order->get_billing_state(); 130 $billing_country_code = $order->get_billing_country(); 125 131 126 132 // Clean special chars. 127 133 if ( isset( $setttings['cleanchars'] ) && 'on' === $setttings['cleanchars'] ) { 128 $contact_name = self::clean_special_chars( $contact_name ); 129 $first_name = self::clean_special_chars( $first_name ); 130 $last_name = self::clean_special_chars( $last_name ); 134 $contact_name = self::clean_special_chars( $contact_name ); 135 $first_name = self::clean_special_chars( $first_name ); 136 $last_name = self::clean_special_chars( $last_name ); 137 $billing_company = self::clean_special_chars( $billing_company ); 138 $billing_address = self::clean_special_chars( $billing_address ); 139 $billing_city = self::clean_special_chars( $billing_city ); 140 $billing_postcode = self::clean_special_chars( $billing_postcode ); 141 $billing_state_code = self::clean_special_chars( $billing_state_code ); 142 $billing_country_code = self::clean_special_chars( $billing_country_code ); 131 143 } 132 144 133 145 // State and Country. 134 $billing_country_code = $order->get_billing_country(); 135 $billing_state_code = $order->get_billing_state(); 136 $order_description = get_bloginfo( 'name', 'display' ) . ' WooCommerce ' . $order_label_id; 137 $billing_state = ! empty( $billing_state_code ) && ! empty( $billing_country_code ) ? WC()->countries->get_states( $billing_country_code )[ $billing_state_code ] : ''; 146 $order_description = get_bloginfo( 'name', 'display' ) . ' WooCommerce ' . $order_label_id; 147 $woo_states = WC()->countries->get_states( $billing_country_code ); 148 $billing_state = ! empty( $billing_state_code ) && ! empty( $billing_country_code ) && ! empty( $woo_states[ $billing_state_code ] ) ? $woo_states[ $billing_state_code ] : ''; 138 149 139 150 $contact_code = self::get_billing_vat( $order ); … … 162 173 'woocommerceStore' => get_bloginfo( 'name', 'display' ), 163 174 'contactEmail' => $order->get_billing_email(), 164 'contactCompany' => $ order->get_billing_company(),175 'contactCompany' => $billing_company, 165 176 'contact_phone' => $order->get_billing_phone(), 166 'contactAddress' => $ order->get_billing_address_1() . ',' . $order->get_billing_address_2(),167 'contactCity' => $ order->get_billing_city(),168 'contactCp' => $ order->get_billing_postcode(),177 'contactAddress' => $billing_address, 178 'contactCity' => $billing_city, 179 'contactCp' => $billing_postcode, 169 180 'contactProvince' => $billing_state, 170 181 'contactCountryCode' => $billing_country_code, … … 205 216 } 206 217 207 $wc_payment_method = $order->get_payment_method();208 $ order_data['notes'] .= ' ';209 switch ( $wc_payment_method) {210 case 'cod':211 $order_data['notes'] .= __( 'Paid by cash', 'connect-ecommerce' );212 break;213 case 'cheque':214 $order_data['notes'] .= __( 'Paid by check', 'connect-ecommerce' );215 break;216 case 'paypal':217 $order_data['notes'] .= __( 'Paid by paypal', 'connect-ecommerce' );218 break;219 case 'bacs':220 $order_data['notes'] .= __( 'Paid by bank transfer', 'connect-ecommerce' );221 break;222 default:223 $order_data['notes'] .= __( 'Paid by', 'connect-ecommerce' ) . ' ' . (string) $wc_payment_method;224 break;225 } 226 $result_items = self::review_items( $order, $option_prefix );218 // Payment method. 219 $wc_payment_method = $order->get_payment_method(); 220 if ( ! empty( $wc_payment_method ) ) { 221 $order_data['paymentMethod'] = $wc_payment_method; 222 } 223 $settings_prod_mergevars = isset( $setttings['prod_mergevars'] ) ? $setttings['prod_mergevars'] : ''; 224 if ( ! empty( $settings_prod_mergevars ) ) { 225 foreach ( $settings_prod_mergevars as $key => $value ) { 226 if ( false === strpos( $key, 'paymentmethods|' ) ) { 227 continue; 228 } 229 $payment_method = explode( '|', $key ); 230 $payment_method_woo = explode( '|', $value ); 231 if ( $payment_method_woo[1] === $wc_payment_method ) { 232 $order_data['paymentMethodId'] = $payment_method[1]; 233 } 234 } 235 } 236 237 $result_items = self::review_items( $order, $option_prefix ); 227 238 $order_data['items'] = $result_items['items']; 228 239 -
connect-ecommerce/tags/3.1.6/includes/Helpers/PROD.php
r3362630 r3375637 42 42 } 43 43 44 if ( empty( $item['sku'] ) ) {44 if ( empty( $item['sku'] ) && empty( $item['variants'] ) ) { // Only for simple products. 45 45 return array( 46 46 'status' => 'error', … … 49 49 ); 50 50 } 51 $item_sku = ! empty( $item['sku'] ) ? $item['sku'] : ''; 51 52 52 53 if ( empty( $item['variants'] ) && ( 'variants' === $item['kind'] || 'variable' === $item['kind'] ) ) { … … 64 65 65 66 if ( empty( $post_id ) ) { 66 $post_id = self::find_product( $item ['sku'] ?? '');67 $post_id = self::find_product( $item_sku ); 67 68 $is_new_product = empty( $post_id ) ? true : false; 68 69 } … … 74 75 $msg_product_synced = __( 'Product synced: ', 'connect-ecommerce' ); 75 76 76 if ( ! $is_filtered && $item ['sku']&& 'simple' === $item['kind'] ) {77 if ( ! $is_filtered && $item_sku && 'simple' === $item['kind'] ) { 77 78 $result_post = self::sync_product_simple( $settings, $item, $api_erp, false, $post_id ); 78 79 $post_id = $result_post['post_id'] ?? 0; … … 86 87 // Activar para buscar un archivo. 87 88 $any_variant_sku = false; 88 89 89 90 foreach ( $item['variants'] as $variant ) { 90 if ( ! $variant['sku']) {91 if ( empty( $variant['sku'] ) ) { 91 92 break; 92 93 } else { … … 104 105 if ( $post_id ) { 105 106 $parent_product = wc_get_product( $post_id ); 106 if ( $parent_product && ! $parent_product->get_sku() && ! empty( $item['sku'] )) {107 if ( $parent_product && ! $parent_product->get_sku() && $item_sku ) { 107 108 try { 108 $parent_product->set_sku( $item ['sku']);109 $parent_product->set_sku( $item_sku ); 109 110 $parent_product->save(); 110 } catch ( \Exception $e ) {} 111 } catch ( \Exception $e ) { 112 // Error. 113 return array( 114 'status' => 'error', 115 'post_id' => $post_id, 116 'message' => __( 'Error setting SKU to parent product: ', 'connect-ecommerce' ) . $e->getMessage(), 117 ); 118 } 111 119 } 112 120 unset( $parent_product ); … … 120 128 $post_id = $result_prod['prod_id'] ?? 0; 121 129 $message .= 0 === $post_id || false === $post_id ? $msg_product_created : $msg_product_synced; 122 $message .= $item['name'] . '. SKU: ' . $item ['sku']. '(' . $item['kind'] . ') ' . $result_prod['message'] ?? '';130 $message .= $item['name'] . '. SKU: ' . $item_sku . '(' . $item['kind'] . ') ' . $result_prod['message'] ?? ''; 123 131 } 124 132 } elseif ( ! $is_filtered && 'pack' === $item['kind'] && $plugin_pack_active ) { 125 $post_id = ! empty( $post_id ) ? $post_id : self::find_product( $item ['sku']);133 $post_id = ! empty( $post_id ) ? $post_id : self::find_product( $item_sku ); 126 134 127 135 if ( ! $post_id ) { … … 129 137 wp_set_object_terms( $post_id, 'woosb', 'product_type' ); 130 138 } 131 if ( $post_id && $item ['sku']&& 'pack' === $item['kind'] ) {139 if ( $post_id && $item_sku && 'pack' === $item['kind'] ) { 132 140 // Create subproducts before. 133 141 $pack_items = ''; … … 153 161 ); 154 162 } 155 $message .= $item['name'] . '. SKU: ' . $item ['sku']. ' (' . $item['kind'] . ')' . $result_prod['message'] ?? '';163 $message .= $item['name'] . '. SKU: ' . $item_sku . ' (' . $item['kind'] . ')' . $result_prod['message'] ?? ''; 156 164 } elseif ( ! $is_filtered && 'pack' === $item['kind'] && ! $plugin_pack_active ) { 157 165 $message .= '<span class="warning">' . __( 'Product needs Plugin to import: ', 'connect-ecommerce' ); … … 161 169 // Product not synced without SKU. 162 170 $message .= '<span class="warning">' . __( 'Product filtered to not import: ', 'connect-ecommerce' ) . $item['name'] . '(' . $item['kind'] . ') </span>'; 163 } elseif ( '' === $item ['sku']&& 'simple' === $item['kind'] ) {171 } elseif ( '' === $item_sku && 'simple' === $item['kind'] ) { 164 172 // Product not synced without SKU. 165 173 return array( … … 257 265 $message = ''; 258 266 $product = null; 267 $item_sku = ! empty( $item['sku'] ) ? $item['sku'] : ''; 259 268 260 269 // Start. … … 330 339 331 340 $product_props = array_merge( $product_props, $product_props_new ); 332 $product_props['sku'] = $item ['sku'] ?? '';341 $product_props['sku'] = $item_sku; 333 342 // Set properties and save. 334 343 $product->set_props( $product_props ); … … 546 555 } 547 556 } 557 $variations_atachment_ids = array(); 548 558 foreach ( $item['variants'] as $variant ) { 549 559 $variation_id = 0; // default value. … … 639 649 // Add image to variation. 640 650 if ( ! empty( $variant['image'] ) ) { 641 self::attach_image_to_product( $variation_id, $variant['image'] ); 642 } 651 $variations_atachment_ids[] = self::attach_image_to_product( $variation_id, $variant['image'] ); 652 } 653 } 654 if ( ! empty( $variations_atachment_ids ) ) { 655 $product->set_gallery_image_ids( $variations_atachment_ids ); 643 656 } 644 657 $var_prop = TAX::make_attributes( $attributes, true ); … … 892 905 * @param array|string $image Image data. 893 906 * @param bool $first_image If is the first image for thumbnail. 894 * @return void 907 * 908 * @return int $attach_id Attachment ID. 895 909 */ 896 910 private static function attach_image_to_product( $product_id, $image_data, $first_image = true ) { … … 928 942 // Check for download errors 929 943 if ( is_wp_error( $handle_file['tmp_name'] ) ) { 930 return ;944 return 0; 931 945 } 932 946 … … 964 978 update_post_meta( $product_id, '_product_image_gallery', $gallery ); 965 979 } 980 981 return $attach_id; 966 982 } 967 983 -
connect-ecommerce/tags/3.1.6/includes/assets/admin.css
r3362630 r3375637 80 80 .repeater-section .product-mergevars { 81 81 display: grid; 82 grid-template-columns: 3fr 1fr 3fr 1fr;82 grid-template-columns: 3fr 1fr 1fr 3fr 1fr; 83 83 } 84 84 -
connect-ecommerce/tags/3.1.6/readme.txt
r3362630 r3375637 6 6 Requires PHP: 7.4 7 7 Tested up to: 6.8 8 Stable tag: 3.1. 59 Version: 3.1. 58 Stable tag: 3.1.6 9 Version: 3.1.6 10 10 License: GPL2 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 45 45 - Adds the NIF/CIF field for proper invoicing. 46 46 - Complies with Verifactu and GDPR. 47 - For ERPs that support it, you can send the payment method. 47 48 48 49 This plugin serves as the foundation for various connectors. The free version supports: 49 50 - [Clientify](https://close.marketing/likes/clientify/) 51 52 **Merge variables** 53 You can use this section to merge variables from ERP to WooCommerce. That means that you can merge categories, attributes, products, custom fields, taxonomies, etc. 54 55 You will need to add Payment methods to merge variables to send the payment method to the ERP. 50 56 51 57 Premium connectors include: … … 99 105 100 106 == Changelog == 107 108 = 3.1.6 = 109 * Enhancement: Added variation images to product gallery for APIs that allows images in variations. 110 * Enhancement: Added support to import variable products without SKU in parent. 111 * Fixed: error saving category separator. 112 * Enhancement: Added support to payment methods from API. 113 * Enhancement: Added support to smart doctype in Holded. 101 114 102 115 = 3.1.5 = -
connect-ecommerce/tags/3.1.6/vendor/composer/installed.php
r3362630 r3375637 2 2 'root' => array( 3 3 'name' => 'closemarketing/connect-ecommerce', 4 'pretty_version' => '3.1. 5',5 'version' => '3.1. 5.0',6 'reference' => 'c 63957d4716f5035636c124eaa23a6694d6e078f',4 'pretty_version' => '3.1.6', 5 'version' => '3.1.6.0', 6 'reference' => 'c58aa3f1e42e75d62e03e6a22d0846c89ae2f641', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'closemarketing/connect-ecommerce' => array( 14 'pretty_version' => '3.1. 5',15 'version' => '3.1. 5.0',16 'reference' => 'c 63957d4716f5035636c124eaa23a6694d6e078f',14 'pretty_version' => '3.1.6', 15 'version' => '3.1.6.0', 16 'reference' => 'c58aa3f1e42e75d62e03e6a22d0846c89ae2f641', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
connect-ecommerce/trunk/composer.json
r3362630 r3375637 42 42 "prepare-behat-tests": "install-package-tests", 43 43 "test": "phpunit", 44 "test-debug": "XDEBUG_MODE=debug XDEBUG_TRIGGER=1 phpunit", 44 45 "test-install": "bash bin/install-wp-tests.sh wordpress_test root 'root' 127.0.0.1 latest" 45 46 }, -
connect-ecommerce/trunk/connect-ecommerce.php
r3362630 r3375637 6 6 * Author: Closetechnology 7 7 * Author URI: https://close.technology/ 8 * Version: 3.1. 58 * Version: 3.1.6 9 9 * Requires PHP: 7.4 10 10 * Requires at least: 6.3 … … 14 14 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 15 15 * 16 * Prefix: conecom_ 17 * 16 18 * @package WordPress 17 19 */ … … 19 21 defined( 'ABSPATH' ) || exit; 20 22 21 define( 'CONECOM_VERSION', '3.1. 5' );23 define( 'CONECOM_VERSION', '3.1.6' ); 22 24 define( 'CONECOM_FILE', __FILE__ ); 23 25 define( 'CONECOM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
connect-ecommerce/trunk/includes/Admin/Orders.php
r3362630 r3375637 66 66 return; 67 67 } 68 $this->options = $options[ $connector ]; 69 $this->settings = get_option( 'connect_ecommerce' )[ $connector ] ?? array(); 70 $apiname = 'Connect_Ecommerce_' . $this->options['name']; 71 $this->connapi_erp = new $apiname( $options ); 72 $ecstatus = isset( $this->settings['ecstatus'] ) ? $this->settings['ecstatus'] : $this->options['order_only_order_completed']; 73 $this->meta_key_order = '_' . $this->options['slug'] . '_invoice_id'; 68 $this->options = $options[ $connector ]; 69 $this->settings = get_option( 'connect_ecommerce' )[ $connector ] ?? array(); 70 $this->settings['prod_mergevars'] = get_option( 'connect_ecommerce_prod_mergevars' )['prod_mergevars'] ?? array(); 71 $apiname = 'Connect_Ecommerce_' . $this->options['name']; 72 $this->connapi_erp = new $apiname( $options ); 73 $ecstatus = isset( $this->settings['ecstatus'] ) ? $this->settings['ecstatus'] : $this->options['order_only_order_completed']; 74 $this->meta_key_order = '_' . $this->options['slug'] . '_invoice_id'; 74 75 75 76 add_action( 'wp_ajax_connect_ecommerce_sync_orders', array( $this, 'sync_orders' ) ); -
connect-ecommerce/trunk/includes/Admin/Settings.php
r3362630 r3375637 705 705 add_settings_section( 706 706 'connect_ecommerce_prod_mergevars_section', 707 __( 'Merge variables from product attributes to custom fields', 'connect-ecommerce' ),707 __( 'Merge variables from ERP to WooCommerce', 'connect-ecommerce' ), 708 708 array( $this, 'section_info_prod_mergevars' ), 709 709 'connect_ecommerce_prod_mergevars' … … 712 712 add_settings_field( 713 713 'wcpimh_prod_mergevars', 714 __( 'Merge fields with product', 'connect-ecommerce' ),714 __( 'Merge fields', 'connect-ecommerce' ), 715 715 array( $this, 'prod_mergevars_callback' ), 716 716 'connect_ecommerce_prod_mergevars', … … 928 928 $admin_settings = [ 929 929 $connector => [ 930 'api' => '',931 'idcentre' => '',932 'url' => '',933 'username' => '',934 'password' => '',935 'company' => '',936 'company_id' => '',937 'domain' => '',938 'dbname' => '',939 'stock' => 'no',940 'prodst' => 'draft',941 'virtual' => 'no',942 'backorders' => 'no',943 'catsep' => '',944 'catattr' => '',945 'filter' => '',930 'api' => '', 931 'idcentre' => '', 932 'url' => '', 933 'username' => '', 934 'password' => '', 935 'company' => '', 936 'company_id' => '', 937 'domain' => '', 938 'dbname' => '', 939 'stock' => 'no', 940 'prodst' => 'draft', 941 'virtual' => 'no', 942 'backorders' => 'no', 943 'catsep' => '', 944 'catattr' => '', 945 'filter' => '', 946 946 'pricesale_discount' => '', 947 'filter_sku' => '',948 'tax_option' => 'no',949 'rates' => 'default',950 'catnp' => 'yes',951 'doctype' => 'invoice',952 'cleanchars' => '',953 'approve_document' => 'no',954 'series' => '',955 'freeorder' => 'no',956 'ecstatus' => 'all',957 'order_tags' => '',958 'design_id' => '',959 'sync' => 'no',960 'sync_num' => 5,961 'sync_email' => 'yes',962 'prod_weight_eq' => '',963 'debug_log' => 'no',947 'filter_sku' => '', 948 'tax_option' => 'no', 949 'rates' => 'default', 950 'catnp' => 'yes', 951 'doctype' => 'invoice', 952 'cleanchars' => '', 953 'approve_document' => 'no', 954 'series' => '', 955 'freeorder' => 'no', 956 'ecstatus' => 'all', 957 'order_tags' => '', 958 'design_id' => '', 959 'sync' => 'no', 960 'sync_num' => 5, 961 'sync_email' => 'yes', 962 'prod_weight_eq' => '', 963 'debug_log' => 'no', 964 964 ], 965 965 ]; … … 1255 1255 } 1256 1256 printf( 1257 '<input class="regular-text" type="text" name="connect_ecommerce[<?php echo esc_html( $this->connector ); ?>][catsep]" id="wcpimh_catsep" value="%s" %s>', 1257 '<input class="regular-text" type="text" name="connect_ecommerce[%s][catsep]" id="wcpimh_catsep" value="%s" %s>', 1258 esc_html( $this->connector ), 1258 1259 isset( $this->settings['catsep'] ) ? esc_attr( $this->settings['catsep'] ) : '', 1259 1260 ! empty( $prod_category_fixed ) ? ' readonly' : '' … … 1435 1436 */ 1436 1437 public function doctype_callback() { 1438 $documents_type = array( 1439 'nosync' => __( 'Not sync', 'connect-ecommerce' ), 1440 'smart' => __( 'Smart', 'connect-ecommerce' ), 1441 'invoice' => __( 'Invoice', 'connect-ecommerce' ), 1442 'salesreceipt' => __( 'Sales receipt', 'connect-ecommerce' ), 1443 'salesorder' => __( 'Sales order', 'connect-ecommerce' ), 1444 'waybill' => __( 'Waybill', 'connect-ecommerce' ), 1445 ); 1437 1446 $doctype = isset( $this->settings['doctype'] ) ? $this->settings['doctype'] : 'invoice'; 1438 1447 ?> 1439 1448 <select name="connect_ecommerce[<?php echo esc_html( $this->connector ); ?>][doctype]" id="wcpimh_doctype"> 1440 <option value="nosync" <?php selected( $doctype, 'nosync' ); ?>><?php esc_html_e( 'Not sync', 'connect-ecommerce' ); ?></option> <option value="invoice" <?php selected( $doctype, 'invoice' ); ?>><?php esc_html_e( 'Invoice', 'connect-ecommerce' ); ?></option> <option value="salesreceipt" <?php selected( $doctype, 'salesreceipt' ); ?>><?php esc_html_e( 'Sales receipt', 'connect-ecommerce' ); ?></option> <option value="salesorder" <?php selected( $doctype, 'salesorder' ); ?>><?php esc_html_e( 'Sales order', 'connect-ecommerce' ); ?></option> <option value="waybill" <?php selected( $doctype, 'waybill' ); ?>><?php esc_html_e( 'Waybill', 'connect-ecommerce' ); ?></option> 1449 <?php 1450 foreach ( $documents_type as $value => $label ) { 1451 echo '<option value="' . esc_html( $value ) . '" '; 1452 selected( $value, $doctype ); 1453 echo '>' . esc_html( $label ) . '</option>'; 1454 } 1455 ?> 1441 1456 </select> 1442 1457 <?php … … 1634 1649 */ 1635 1650 public function prod_mergevars_callback() { 1636 $product_fields = PROD::get_all_product_fields(); 1637 $custom_fields = PROD::get_all_custom_fields(); 1638 $custom_taxonomies = TAX::get_all_custom_taxonomies(); 1639 $product_cat_terms = TAX::get_terms_product_cat(); 1640 $attribute_fields = $this->connapi_erp->get_product_attributes(); 1651 $product_fields = PROD::get_all_product_fields(); 1652 $custom_fields = PROD::get_all_custom_fields(); 1653 $custom_taxonomies = TAX::get_all_custom_taxonomies(); 1654 $product_cat_terms = TAX::get_terms_product_cat(); 1655 $attribute_fields = $this->connapi_erp->get_product_attributes(); 1656 $payment_methods_api = method_exists( $this->connapi_erp, 'get_payment_methods' ) ? $this->connapi_erp->get_payment_methods() : array(); 1657 $payment_methods = WC()->payment_gateways()->get_available_payment_gateways(); 1641 1658 1642 1659 $settings_mergevars = ! empty( $this->settings_prod_mergevars['prod_mergevars'] ) ? $this->settings_prod_mergevars['prod_mergevars'] : array(); … … 1660 1677 $size = ! empty( $settings_mergevars ) ? count( $settings_mergevars ) : 0; 1661 1678 for ( $idx = 0, $size; $idx <= $size; ++$idx ) { 1662 $attrprod = isset( $saved_attr[ $idx ]['attrprod'] ) ? $saved_attr[ $idx ]['attrprod'] : ''; 1679 $attrprod = isset( $saved_attr[ $idx ]['attrprod'] ) ? $saved_attr[ $idx ]['attrprod'] : ''; 1680 $attrprod_label = ''; 1663 1681 ?> 1664 1682 <div class="product-mergevars repeating" style="border: 1px solid #ccc; padding: 10px; margin-bottom: 10px;"> … … 1668 1686 <?php 1669 1687 foreach ( $attribute_fields as $attribute ) { 1688 if ( empty( $attribute['elements'] ) ) { 1689 continue; 1690 } 1670 1691 ?> 1671 1692 <optgroup label="<?php echo esc_html( $attribute['name'] ); ?>"> … … 1676 1697 selected( $option_id, $attrprod ); 1677 1698 echo '>' . esc_html( $value ) . '</option>'; 1699 1700 if ( $option_id === $attrprod ) { 1701 $attrprod_label = $attribute['name']; 1702 } 1678 1703 } 1679 1704 ?> … … 1682 1707 } 1683 1708 ?> 1709 <?php if ( ! empty( $payment_methods_api ) ) { ?> 1710 <optgroup label="<?php esc_html_e( 'Payment Methods', 'connect-ecommerce' ); ?>"> 1711 <?php 1712 foreach ( $payment_methods_api as $key => $value ) { 1713 echo '<option value="' . esc_html( $key ) . '" '; 1714 selected( $key, $attrprod ); 1715 echo '>' . esc_html( $value ) . '</option>'; 1716 1717 if ( $key === $attrprod ) { 1718 $attrprod_label = __( 'Payment Method', 'connect-ecommerce' ); 1719 } 1720 } 1721 ?> 1722 </optgroup> 1723 <?php } ?> 1684 1724 </select> 1685 1725 </div> 1726 <span class="attrprod-label"> 1727 <?php 1728 if ( ! empty( $attrprod_label ) ) { 1729 echo esc_html( $attrprod_label ); 1730 } 1731 ?> 1732 </span> 1686 1733 <span class="dashicons dashicons-arrow-right-alt2"></span> 1687 1734 <div class="save-item"> 1688 <?php 1735 <?php 1689 1736 $saved_custom_field = isset( $saved_attr[ $idx ]['custom_field'] ) ? $saved_attr[ $idx ]['custom_field'] : ''; 1690 1737 $all_fields = array_merge( $product_fields, $product_cat_terms, $custom_taxonomies, $custom_fields ); … … 1733 1780 ?> 1734 1781 </optgroup> 1782 <?php if ( ! empty( $payment_methods_api ) ) { ?> 1783 <optgroup label="<?php esc_html_e( 'Payment Methods', 'connect-ecommerce' ); ?>"> 1784 <?php 1785 foreach ( $payment_methods as $method ) { 1786 $key = 'cf|' . $method->id; 1787 ?> 1788 <option value="<?php echo esc_html( $key ); ?>" <?php selected( $key, $saved_custom_field ); ?>><?php echo esc_html( $method->title ); ?></option> 1789 <?php } ?> 1790 </optgroup> 1791 <?php } ?> 1735 1792 </select> 1736 1793 </div> -
connect-ecommerce/trunk/includes/Helpers/ORDER.php
r3362630 r3375637 121 121 $contact_name = $order->get_billing_company(); 122 122 } 123 $first_name = $order->get_billing_first_name(); 124 $last_name = $order->get_billing_last_name(); 123 $first_name = $order->get_billing_first_name(); 124 $last_name = $order->get_billing_last_name(); 125 $billing_company = $order->get_billing_company(); 126 $billing_address = $order->get_billing_address_1() . ',' . $order->get_billing_address_2(); 127 $billing_city = $order->get_billing_city(); 128 $billing_postcode = $order->get_billing_postcode(); 129 $billing_state_code = $order->get_billing_state(); 130 $billing_country_code = $order->get_billing_country(); 125 131 126 132 // Clean special chars. 127 133 if ( isset( $setttings['cleanchars'] ) && 'on' === $setttings['cleanchars'] ) { 128 $contact_name = self::clean_special_chars( $contact_name ); 129 $first_name = self::clean_special_chars( $first_name ); 130 $last_name = self::clean_special_chars( $last_name ); 134 $contact_name = self::clean_special_chars( $contact_name ); 135 $first_name = self::clean_special_chars( $first_name ); 136 $last_name = self::clean_special_chars( $last_name ); 137 $billing_company = self::clean_special_chars( $billing_company ); 138 $billing_address = self::clean_special_chars( $billing_address ); 139 $billing_city = self::clean_special_chars( $billing_city ); 140 $billing_postcode = self::clean_special_chars( $billing_postcode ); 141 $billing_state_code = self::clean_special_chars( $billing_state_code ); 142 $billing_country_code = self::clean_special_chars( $billing_country_code ); 131 143 } 132 144 133 145 // State and Country. 134 $billing_country_code = $order->get_billing_country(); 135 $billing_state_code = $order->get_billing_state(); 136 $order_description = get_bloginfo( 'name', 'display' ) . ' WooCommerce ' . $order_label_id; 137 $billing_state = ! empty( $billing_state_code ) && ! empty( $billing_country_code ) ? WC()->countries->get_states( $billing_country_code )[ $billing_state_code ] : ''; 146 $order_description = get_bloginfo( 'name', 'display' ) . ' WooCommerce ' . $order_label_id; 147 $woo_states = WC()->countries->get_states( $billing_country_code ); 148 $billing_state = ! empty( $billing_state_code ) && ! empty( $billing_country_code ) && ! empty( $woo_states[ $billing_state_code ] ) ? $woo_states[ $billing_state_code ] : ''; 138 149 139 150 $contact_code = self::get_billing_vat( $order ); … … 162 173 'woocommerceStore' => get_bloginfo( 'name', 'display' ), 163 174 'contactEmail' => $order->get_billing_email(), 164 'contactCompany' => $ order->get_billing_company(),175 'contactCompany' => $billing_company, 165 176 'contact_phone' => $order->get_billing_phone(), 166 'contactAddress' => $ order->get_billing_address_1() . ',' . $order->get_billing_address_2(),167 'contactCity' => $ order->get_billing_city(),168 'contactCp' => $ order->get_billing_postcode(),177 'contactAddress' => $billing_address, 178 'contactCity' => $billing_city, 179 'contactCp' => $billing_postcode, 169 180 'contactProvince' => $billing_state, 170 181 'contactCountryCode' => $billing_country_code, … … 205 216 } 206 217 207 $wc_payment_method = $order->get_payment_method();208 $ order_data['notes'] .= ' ';209 switch ( $wc_payment_method) {210 case 'cod':211 $order_data['notes'] .= __( 'Paid by cash', 'connect-ecommerce' );212 break;213 case 'cheque':214 $order_data['notes'] .= __( 'Paid by check', 'connect-ecommerce' );215 break;216 case 'paypal':217 $order_data['notes'] .= __( 'Paid by paypal', 'connect-ecommerce' );218 break;219 case 'bacs':220 $order_data['notes'] .= __( 'Paid by bank transfer', 'connect-ecommerce' );221 break;222 default:223 $order_data['notes'] .= __( 'Paid by', 'connect-ecommerce' ) . ' ' . (string) $wc_payment_method;224 break;225 } 226 $result_items = self::review_items( $order, $option_prefix );218 // Payment method. 219 $wc_payment_method = $order->get_payment_method(); 220 if ( ! empty( $wc_payment_method ) ) { 221 $order_data['paymentMethod'] = $wc_payment_method; 222 } 223 $settings_prod_mergevars = isset( $setttings['prod_mergevars'] ) ? $setttings['prod_mergevars'] : ''; 224 if ( ! empty( $settings_prod_mergevars ) ) { 225 foreach ( $settings_prod_mergevars as $key => $value ) { 226 if ( false === strpos( $key, 'paymentmethods|' ) ) { 227 continue; 228 } 229 $payment_method = explode( '|', $key ); 230 $payment_method_woo = explode( '|', $value ); 231 if ( $payment_method_woo[1] === $wc_payment_method ) { 232 $order_data['paymentMethodId'] = $payment_method[1]; 233 } 234 } 235 } 236 237 $result_items = self::review_items( $order, $option_prefix ); 227 238 $order_data['items'] = $result_items['items']; 228 239 -
connect-ecommerce/trunk/includes/Helpers/PROD.php
r3362630 r3375637 42 42 } 43 43 44 if ( empty( $item['sku'] ) ) {44 if ( empty( $item['sku'] ) && empty( $item['variants'] ) ) { // Only for simple products. 45 45 return array( 46 46 'status' => 'error', … … 49 49 ); 50 50 } 51 $item_sku = ! empty( $item['sku'] ) ? $item['sku'] : ''; 51 52 52 53 if ( empty( $item['variants'] ) && ( 'variants' === $item['kind'] || 'variable' === $item['kind'] ) ) { … … 64 65 65 66 if ( empty( $post_id ) ) { 66 $post_id = self::find_product( $item ['sku'] ?? '');67 $post_id = self::find_product( $item_sku ); 67 68 $is_new_product = empty( $post_id ) ? true : false; 68 69 } … … 74 75 $msg_product_synced = __( 'Product synced: ', 'connect-ecommerce' ); 75 76 76 if ( ! $is_filtered && $item ['sku']&& 'simple' === $item['kind'] ) {77 if ( ! $is_filtered && $item_sku && 'simple' === $item['kind'] ) { 77 78 $result_post = self::sync_product_simple( $settings, $item, $api_erp, false, $post_id ); 78 79 $post_id = $result_post['post_id'] ?? 0; … … 86 87 // Activar para buscar un archivo. 87 88 $any_variant_sku = false; 88 89 89 90 foreach ( $item['variants'] as $variant ) { 90 if ( ! $variant['sku']) {91 if ( empty( $variant['sku'] ) ) { 91 92 break; 92 93 } else { … … 104 105 if ( $post_id ) { 105 106 $parent_product = wc_get_product( $post_id ); 106 if ( $parent_product && ! $parent_product->get_sku() && ! empty( $item['sku'] )) {107 if ( $parent_product && ! $parent_product->get_sku() && $item_sku ) { 107 108 try { 108 $parent_product->set_sku( $item ['sku']);109 $parent_product->set_sku( $item_sku ); 109 110 $parent_product->save(); 110 } catch ( \Exception $e ) {} 111 } catch ( \Exception $e ) { 112 // Error. 113 return array( 114 'status' => 'error', 115 'post_id' => $post_id, 116 'message' => __( 'Error setting SKU to parent product: ', 'connect-ecommerce' ) . $e->getMessage(), 117 ); 118 } 111 119 } 112 120 unset( $parent_product ); … … 120 128 $post_id = $result_prod['prod_id'] ?? 0; 121 129 $message .= 0 === $post_id || false === $post_id ? $msg_product_created : $msg_product_synced; 122 $message .= $item['name'] . '. SKU: ' . $item ['sku']. '(' . $item['kind'] . ') ' . $result_prod['message'] ?? '';130 $message .= $item['name'] . '. SKU: ' . $item_sku . '(' . $item['kind'] . ') ' . $result_prod['message'] ?? ''; 123 131 } 124 132 } elseif ( ! $is_filtered && 'pack' === $item['kind'] && $plugin_pack_active ) { 125 $post_id = ! empty( $post_id ) ? $post_id : self::find_product( $item ['sku']);133 $post_id = ! empty( $post_id ) ? $post_id : self::find_product( $item_sku ); 126 134 127 135 if ( ! $post_id ) { … … 129 137 wp_set_object_terms( $post_id, 'woosb', 'product_type' ); 130 138 } 131 if ( $post_id && $item ['sku']&& 'pack' === $item['kind'] ) {139 if ( $post_id && $item_sku && 'pack' === $item['kind'] ) { 132 140 // Create subproducts before. 133 141 $pack_items = ''; … … 153 161 ); 154 162 } 155 $message .= $item['name'] . '. SKU: ' . $item ['sku']. ' (' . $item['kind'] . ')' . $result_prod['message'] ?? '';163 $message .= $item['name'] . '. SKU: ' . $item_sku . ' (' . $item['kind'] . ')' . $result_prod['message'] ?? ''; 156 164 } elseif ( ! $is_filtered && 'pack' === $item['kind'] && ! $plugin_pack_active ) { 157 165 $message .= '<span class="warning">' . __( 'Product needs Plugin to import: ', 'connect-ecommerce' ); … … 161 169 // Product not synced without SKU. 162 170 $message .= '<span class="warning">' . __( 'Product filtered to not import: ', 'connect-ecommerce' ) . $item['name'] . '(' . $item['kind'] . ') </span>'; 163 } elseif ( '' === $item ['sku']&& 'simple' === $item['kind'] ) {171 } elseif ( '' === $item_sku && 'simple' === $item['kind'] ) { 164 172 // Product not synced without SKU. 165 173 return array( … … 257 265 $message = ''; 258 266 $product = null; 267 $item_sku = ! empty( $item['sku'] ) ? $item['sku'] : ''; 259 268 260 269 // Start. … … 330 339 331 340 $product_props = array_merge( $product_props, $product_props_new ); 332 $product_props['sku'] = $item ['sku'] ?? '';341 $product_props['sku'] = $item_sku; 333 342 // Set properties and save. 334 343 $product->set_props( $product_props ); … … 546 555 } 547 556 } 557 $variations_atachment_ids = array(); 548 558 foreach ( $item['variants'] as $variant ) { 549 559 $variation_id = 0; // default value. … … 639 649 // Add image to variation. 640 650 if ( ! empty( $variant['image'] ) ) { 641 self::attach_image_to_product( $variation_id, $variant['image'] ); 642 } 651 $variations_atachment_ids[] = self::attach_image_to_product( $variation_id, $variant['image'] ); 652 } 653 } 654 if ( ! empty( $variations_atachment_ids ) ) { 655 $product->set_gallery_image_ids( $variations_atachment_ids ); 643 656 } 644 657 $var_prop = TAX::make_attributes( $attributes, true ); … … 892 905 * @param array|string $image Image data. 893 906 * @param bool $first_image If is the first image for thumbnail. 894 * @return void 907 * 908 * @return int $attach_id Attachment ID. 895 909 */ 896 910 private static function attach_image_to_product( $product_id, $image_data, $first_image = true ) { … … 928 942 // Check for download errors 929 943 if ( is_wp_error( $handle_file['tmp_name'] ) ) { 930 return ;944 return 0; 931 945 } 932 946 … … 964 978 update_post_meta( $product_id, '_product_image_gallery', $gallery ); 965 979 } 980 981 return $attach_id; 966 982 } 967 983 -
connect-ecommerce/trunk/includes/assets/admin.css
r3362630 r3375637 80 80 .repeater-section .product-mergevars { 81 81 display: grid; 82 grid-template-columns: 3fr 1fr 3fr 1fr;82 grid-template-columns: 3fr 1fr 1fr 3fr 1fr; 83 83 } 84 84 -
connect-ecommerce/trunk/readme.txt
r3362630 r3375637 6 6 Requires PHP: 7.4 7 7 Tested up to: 6.8 8 Stable tag: 3.1. 59 Version: 3.1. 58 Stable tag: 3.1.6 9 Version: 3.1.6 10 10 License: GPL2 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 45 45 - Adds the NIF/CIF field for proper invoicing. 46 46 - Complies with Verifactu and GDPR. 47 - For ERPs that support it, you can send the payment method. 47 48 48 49 This plugin serves as the foundation for various connectors. The free version supports: 49 50 - [Clientify](https://close.marketing/likes/clientify/) 51 52 **Merge variables** 53 You can use this section to merge variables from ERP to WooCommerce. That means that you can merge categories, attributes, products, custom fields, taxonomies, etc. 54 55 You will need to add Payment methods to merge variables to send the payment method to the ERP. 50 56 51 57 Premium connectors include: … … 99 105 100 106 == Changelog == 107 108 = 3.1.6 = 109 * Enhancement: Added variation images to product gallery for APIs that allows images in variations. 110 * Enhancement: Added support to import variable products without SKU in parent. 111 * Fixed: error saving category separator. 112 * Enhancement: Added support to payment methods from API. 113 * Enhancement: Added support to smart doctype in Holded. 101 114 102 115 = 3.1.5 = -
connect-ecommerce/trunk/vendor/composer/installed.php
r3362630 r3375637 2 2 'root' => array( 3 3 'name' => 'closemarketing/connect-ecommerce', 4 'pretty_version' => '3.1. 5',5 'version' => '3.1. 5.0',6 'reference' => 'c 63957d4716f5035636c124eaa23a6694d6e078f',4 'pretty_version' => '3.1.6', 5 'version' => '3.1.6.0', 6 'reference' => 'c58aa3f1e42e75d62e03e6a22d0846c89ae2f641', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'closemarketing/connect-ecommerce' => array( 14 'pretty_version' => '3.1. 5',15 'version' => '3.1. 5.0',16 'reference' => 'c 63957d4716f5035636c124eaa23a6694d6e078f',14 'pretty_version' => '3.1.6', 15 'version' => '3.1.6.0', 16 'reference' => 'c58aa3f1e42e75d62e03e6a22d0846c89ae2f641', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.