{"id":255,"date":"2014-09-07T10:05:14","date_gmt":"2014-09-07T08:05:14","guid":{"rendered":"http:\/\/my-opinions.info\/?p=255"},"modified":"2014-09-08T08:35:23","modified_gmt":"2014-09-08T06:35:23","slug":"drobnoe-kolichestvo-ubercart-3","status":"publish","type":"post","link":"https:\/\/uw-t.com\/en\/drupal\/drobnoe-kolichestvo-ubercart-3","title":{"rendered":"\u0414\u0440\u043e\u0431\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e ubercart 3"},"content":{"rendered":"<p>ubercard 3.5 \u043d\u0430\u0448\u0435\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043a\u043e\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438<br \/>\n\/\/ making the product quantities FLOAT instead INTEGER Drupal 7, Ubercart 3.1<br \/>\n\/\/\/\/ DATABASE CHANGES Four ubercart tables alterations are made from sql terminal (mysql -u ADMIN_USER -p , use DATABASE_NAME )<br \/>\n1) The UC_CART_PRODUCTS table intersect the UC_CARTS table and the UC_PRODUCTS table. The column \u0446\u2552\u0411\u250c\u255b\u0435\u2320qty\u0446\u2552\u0411\u250c\u255b\u0431\u00b2 is the one to ajust. Here is the MySQL statement that will modify the column to a FLOAT data type: <\/p>\n<p><strong><code>ALTER TABLE `uc_cart_products` MODIFY COLUMN `qty` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 0;<br \/>\n<\/code><\/strong><br \/>\n2) The UC_ORDERS table holds all the orders created. The column to adjust is \u0446\u2552\u0411\u250c\u255b\u0435\u2320product_count\u0446\u2552\u0411\u250c\u255b\u0431\u00b2.<\/p>\n<p><strong><code>ALTER TABLE `uc_orders` MODIFY COLUMN `product_count` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 0; 3) The UC_PRODUCTS table contains a<br \/>\n<\/code><\/strong><br \/>\ndefault_qty field. This value gets inserted into both the product edit page and the product view page (for the customer). I think it would be a good idea to show the customer how many decimal places one may use. <\/p>\n<p><strong><code>ALTER TABLE `uc_products` MODIFY COLUMN `default_qty` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 1.00;<\/code><\/strong> <\/p>\n<p>4) The UC_ORDER_PRODUCTS table intersects the UC_ORDERS table and the UC_PRODUCTS table. The column to adjust is the \u0446\u2552\u0411\u250c\u255b\u0435\u2320qty\u0446\u2552\u0411\u250c\u255b\u0431\u00b2 column. Here is the MySQL statement that will modify the column to a FLOAT data type: <\/p>\n<p><strong><code>ALTER TABLE `uc_order_products` MODIFY COLUMN `qty` FLOAT(6,2) UNSIGNED NOT NULL DEFAULT 0;<br \/>\n<\/code><\/strong><\/p>\n<p>\/\/\/\/ CODE CHANGES \/\/ FIRST uc_order -&gt; uc_order.install \/\/Change array elements in function to: \/** * Increase maximum order item quantity. *\/<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nfunction uc_order_update_7003() {\r\ndb_change_field('uc_order_products', 'qty', 'qty', array(\r\n'description' =&gt; 'The number of the same product ordered.',\r\n'type' =&gt; 'float',\r\n'precision' =&gt; 6,\r\n'scale' =&gt; 1,\r\n'unsigned' =&gt; TRUE,\r\n'not null' =&gt; TRUE,\r\n'default' =&gt; 1.0,\r\n));\r\n}\r\n\r\n<\/pre>\n<p>\/\/ SECOND<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nuc_order\r\n-&gt;\r\nuc_order.install\r\n\r\nIn $schema&#x5B;'uc_order_products'] change:\r\n\r\n'qty' =&gt; array(\r\n'description' =&gt; 'The number of the same product ordered.',\r\n'type' =&gt; 'int',\r\n'size' =&gt; 'small',\r\n'unsigned' =&gt; TRUE,\r\n'not null' =&gt; TRUE,\r\n'default' =&gt; 0,\r\n),\r\n\r\n<\/pre>\n<p>To:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n'qty' =&gt; array(\r\n'description' =&gt; 'The number of the same product ordered.',\r\n'type' =&gt; 'float',\r\n'precision' =&gt; 6,\r\n'scale' =&gt; 1,\r\n'unsigned' =&gt; TRUE,\r\n'not null' =&gt; TRUE,\r\n'default' =&gt; 1.0,\r\n),\r\n\r\n<\/pre>\n<p>\/\/ THIRD uc_product -&gt; uc_product.module \/\/For possibility of using 0.00 to 1.00 quantites in function uc_product_uc_update_cart_item change: (string 1052) p.s. \u0421 \u043d\u043e\u0432\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c, \u044f \u0441\u043c\u0435\u043d\u0438\u043b \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043e\u043a \ud83d\ude42<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;\/pre&gt;\r\n&lt;pre class=&quot;php&quot;&gt;&lt;code&gt;&lt;span class=&quot;php-keyword&quot;&gt;function&lt;\/span&gt; &lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local active&quot; title=&quot;Implements hook_uc_update_cart_item().&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/drupal\/contributions%21ubercart%21uc_product%21uc_product.module\/function\/uc_product_uc_update_cart_item\/7&quot;&gt;uc_product_uc_update_cart_item&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-variable&quot;&gt;$nid&lt;\/span&gt;, &lt;span class=&quot;php-variable&quot;&gt;$data&lt;\/span&gt; = &lt;span class=&quot;php-keyword&quot;&gt;array&lt;\/span&gt;(), &lt;span class=&quot;php-variable&quot;&gt;$qty&lt;\/span&gt;, &lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt; = &lt;span class=&quot;php-function-or-constant&quot;&gt;NULL&lt;\/span&gt;) {\r\n  &lt;span class=&quot;php-keyword&quot;&gt;if&lt;\/span&gt; (!&lt;span class=&quot;php-variable&quot;&gt;$nid&lt;\/span&gt;) {\r\n    &lt;span class=&quot;php-keyword&quot;&gt;return&lt;\/span&gt; &lt;span class=&quot;php-function-or-constant&quot;&gt;NULL&lt;\/span&gt;;\r\n  }\r\n  &lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt; = !(&lt;span class=&quot;php-function-or-constant&quot;&gt;is_null&lt;\/span&gt;(&lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt;) || &lt;span class=&quot;php-keyword&quot;&gt;empty&lt;\/span&gt;(&lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt;)) ? &lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt; : &lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Returns the unique cart_id of the user.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/drupal\/contributions%21ubercart%21uc_cart%21uc_cart.module\/function\/uc_cart_get_id\/7&quot;&gt;uc_cart_get_id&lt;\/a&gt;&lt;\/span&gt;();\r\n  &lt;span class=&quot;php-keyword&quot;&gt;if&lt;\/span&gt; (&lt;span class=&quot;php-variable&quot;&gt;$qty&lt;\/span&gt; &lt; &lt;span class=&quot;php-constant&quot;&gt;1&lt;\/span&gt;) {\r\n    &lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Removes an item from the cart.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/drupal\/contributions%21ubercart%21uc_cart%21uc_cart.module\/function\/uc_cart_remove_item\/7&quot;&gt;uc_cart_remove_item&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-variable&quot;&gt;$nid&lt;\/span&gt;, &lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt;, &lt;span class=&quot;php-variable&quot;&gt;$data&lt;\/span&gt;);\r\n  }\r\n  &lt;span class=&quot;php-keyword&quot;&gt;else&lt;\/span&gt; {\r\n    &lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Returns a new UpdateQuery object for the active database.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/drupal\/drupal%21includes%21database%21database.inc\/function\/db_update\/7&quot;&gt;db_update&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-string&quot;&gt;'uc_cart_products'&lt;\/span&gt;)\r\n      -&gt;&lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Multiple implementations exist.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/search\/7\/fields&quot;&gt;fields&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-keyword&quot;&gt;array&lt;\/span&gt;(\r\n      &lt;span class=&quot;php-string&quot;&gt;'qty'&lt;\/span&gt; =&gt; &lt;span class=&quot;php-variable&quot;&gt;$qty&lt;\/span&gt;, \r\n      &lt;span class=&quot;php-string&quot;&gt;'changed'&lt;\/span&gt; =&gt; &lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Time of the current request in seconds elapsed since the Unix Epoch.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/drupal\/drupal%21includes%21bootstrap.inc\/constant\/REQUEST_TIME\/7&quot;&gt;REQUEST_TIME&lt;\/a&gt;&lt;\/span&gt;,\r\n    ))\r\n      -&gt;&lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Multiple implementations exist.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/search\/7\/condition&quot;&gt;condition&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-string&quot;&gt;'nid'&lt;\/span&gt;, &lt;span class=&quot;php-variable&quot;&gt;$nid&lt;\/span&gt;)\r\n      -&gt;&lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Multiple implementations exist.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/search\/7\/condition&quot;&gt;condition&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-string&quot;&gt;'cart_id'&lt;\/span&gt;, &lt;span class=&quot;php-variable&quot;&gt;$cid&lt;\/span&gt;)\r\n      -&gt;&lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Multiple implementations exist.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/search\/7\/condition&quot;&gt;condition&lt;\/a&gt;&lt;\/span&gt;(&lt;span class=&quot;php-string&quot;&gt;'data'&lt;\/span&gt;, &lt;span class=&quot;php-function-or-constant&quot;&gt;serialize&lt;\/span&gt;(&lt;span class=&quot;php-variable&quot;&gt;$data&lt;\/span&gt;))\r\n      -&gt;&lt;span class=&quot;php-function-or-constant&quot;&gt;&lt;a class=&quot;local&quot; title=&quot;Multiple implementations exist.&quot; href=&quot;http:\/\/drupalcontrib.org\/api\/search\/7\/execute&quot;&gt;execute&lt;\/a&gt;&lt;\/span&gt;();\r\n  }\r\n}\r\n<\/pre>\n<p><\/code><br \/>\n&nbsp;<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nif ($qty &lt; 1) {\r\n\r\n\u00a0\r\n\r\n<\/pre>\n<p>CHANGE TO:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nif ($qty == 0) {\r\n\r\n<\/pre>\n<p>\/\/ FOURTH uc_order -&gt; uc_order.admin.inc \/\/Not sure if it's necessary but just in case (string 1125)<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nif (!isset($product&#x5B;'remove']) &amp;&amp; intval($product&#x5B;'qty']) &gt; 0) {\r\n<\/pre>\n<p>CHANGE TO:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nif (!isset($product&#x5B;'remove']) &amp;&amp; ($product&#x5B;'qty']) &gt; 0) {\r\n\r\n<\/pre>\n<p>\/\/FIFTH uc_cart -&gt; uc_cart.install \/\/Not sure if it's necessary but just in case CHANGE TO FLOATS: (string 37)<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n'qty' =&gt; array(\r\n'description' =&gt; 'The number of this product in the cart.',\r\n'type' =&gt; 'float',\r\n'precision' =&gt; 6,\r\n'scale' =&gt; 1,\r\n'unsigned' =&gt; TRUE,\r\n'not null' =&gt; TRUE,\r\n'default' =&gt; 1.0,\r\n\r\n<\/pre>\n<p>AND (string 126)<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nfunction uc_cart_update_7001() {\r\ndb_change_field('uc_cart_products', 'qty', 'qty', array(\r\n'description' =&gt; 'The number of this product in the cart.',\r\n'type' =&gt; 'float',\r\n'precision' =&gt; 6,\r\n'scale' =&gt; 1,\r\n'unsigned' =&gt; TRUE,\r\n'not null' =&gt; TRUE,\r\n'default' =&gt; 1.0,\r\n));\r\n}\r\n\r\n<\/pre>\n<p>\/*uc_store\\uc_store.module*\/ \/*chenge *\/<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nfunction uc_store_validate_uc_quantity(&amp;$element, &amp;$form_state) {\r\nif (!preg_match('\/^\\d+$\/', $element&#x5B;'#value'])) {\r\nform_error($element, t('The quantity must be a number.'));\r\n}\r\nelseif (empty($element&#x5B;'#allow_zero']) &amp;&amp; !$element&#x5B;'#value']) {\r\nform_error($element, t('The quantity cannot be zero.'));\r\n}\r\n}\r\n\r\n<\/pre>\n<p>\/*on*\/<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nfunction uc_store_validate_uc_quantity(&amp;$element, &amp;$form_state) {\r\nif (!preg_match(&quot;\/(&#x5B;0-9\\.-]+)\/&quot;, $element&#x5B;'#value'])) {\r\nform_error($element, t('The quantity must be a number.'));\r\n}\r\nelseif (empty($element&#x5B;'#allow_zero']) &amp;&amp; !$element&#x5B;'#value']) {\r\nform_error($element, t('The quantity cannot be zero.'));\r\n}\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ubercard 3.5 \u043d\u0430\u0448\u0435\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043a\u043e\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 \/\/ making the product quantities FLOAT instead INTEGER Drupal 7, Ubercart 3.1 \/\/\/\/ DATABASE CHANGES Four ubercart tables alterations are made from sql terminal (mysql -u ADMIN_USER -p , use DATABASE_NAME ) 1) The UC_CART_PRODUCTS table intersect the UC_CARTS table and the UC_PRODUCTS table. The column \u0446\u2552\u0411\u250c\u255b\u0435\u2320qty\u0446\u2552\u0411\u250c\u255b\u0431\u00b2 is &hellip; <a href=\"https:\/\/uw-t.com\/en\/drupal\/drobnoe-kolichestvo-ubercart-3\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u0414\u0440\u043e\u0431\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e ubercart 3<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-drupal"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":5,"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":264,"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/posts\/255\/revisions\/264"}],"wp:attachment":[{"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/uw-t.com\/en\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}