{"id":16532149,"date":"2023-03-06T12:24:05","date_gmt":"2023-03-06T12:24:05","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/order_item_qty-in-the-loop-2\/"},"modified":"2023-03-06T12:24:05","modified_gmt":"2023-03-06T12:24:05","slug":"order_item_qty-in-the-loop-2","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/order_item_qty-in-the-loop-2\/","title":{"rendered":"order_item_qty in the loop"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi,<br \/><br \/>I have to add new css style in the invoice when the product quantity is bigger than 5. In my premium plugin version I have filter which I can use for quantity:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('wf_pklist_alter_item_quantiy', 'wt_pklist_item_qty', 10, 5);\n\nfunction wt_pklist_item_qty($order_item_qty, $template_type, $_product, $order_item, $order) {\n\n\t\/* custom code *\/\n\treturn $order_item_qty;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This would need to go in the loop since I need to alter cell only where quantity is bigger than 5 and not the others when qty is smaller<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('wf_pklist_alter_item_quantiy', 'wt_pklist_item_qty', 10, 5);\n\nfunction wt_pklist_item_qty($order_item_qty, $template_type, $_product, $order_item, $order) {\n\n\tif ($order_item_qty &gt; 5) {\n\t\tforeach ($something as $somethings) {\n\t\t\t$order_item_qty .= '&lt;style&gt; .quantity_td { color: #blue; font-size: 29px; } &lt;\/style&gt;';\n\t\t}\n\t}\n\n\treturn $order_item_qty;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If my approach is correct could you help with the foreach loop part?<\/p>\n","protected":false},"template":"","class_list":["post-16532149","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16532149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16532149\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16532149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}