My heart sunk when I learned of Bill Weiland's passing. For many of us he was a great developer with great customer service. For me, he was an inspiration.
Early on, I struggled to learn Miva Merchant and being self-employed there was no one to turn to but the forums. Bill was always there to offer a solution and help me become a better programmer.
Bill epitomized the selfless sharing and community building found on this forum. Bill was always the first to share information and lend a helping hand. He was always supportive and never condescending. He helped build this community that has made Miva especially different than other carts.
With all the help that Bill gave, I too wanted to start giving back to this forum and assist others and started to post answers and solutions. I think Bill's helpfulness was infectious. I made many great personal friends from sharing on this forum.
After the basket:groups array came out in PR8 my QMIN module broke and hasn't been updated so I wrote some code that emulates the functionality of the QMIN module.
So in Bill's memory and I would like to share it.
Step 1. Create a Product Custom Field for quantity minimums
Utilities Settings > Custom Fields > Add >
Type: Product
Code: qmin
Name: Qmin
Field Type: Text
Step 2. Populate Product Qmin data
Products > Custom Fields > Qmin
The data is pipe separated with the data mask of minimum|step1,step2,step3,etc|maximum|. For example, if you sell a product in kits of 100 up to 500 then enter the data 100|100,200,300,400,500|500|. If there is no product minimum then just leave the field blank.
Step 3. Create a page template named Qmin for the quantity select box found on the PROD page.
User Interface > Pages > Add >
Name: Qmin
Description: Qmin quantity select box
Add Items: Buttons, Custom Fields, Product, Product Display, Product Attributes
In the Product Display Tab select and add the custom field Qmin.
Step 4. Create a page template named PREACTION_QTYG
Code: PREACTION_QTYG
Description: Preaction on Basket page to error check Update Quantity form
Assign the item Custom Fields
Step 5: Update PROD template
This will insert the quantity minimum in the text box.
On the PROD > Product Display template find the form input for the quantity and replace with:
Step 6: Update BASK template
This will do a preaction on the update quantity form to make sure the user doesn't enter a quantity lower than the minimum.
On the BASK > Basket Contents tab:
Find the basket:groups array iterator and add just below:
Find the Update Item Quantity Form and add hidden inputs:
Find the Update Item Quantity Input Box and replace:
Add Items > Custom Fields
This is custom code so may not work in every merchant store but you are welcome to try this code and fork it to your taste. This code is for technically minded merchants and may break your store. Future Miva updates may also break this code.
Note: I didn't have user privileges in the Community News section so I posted the memorium here.
Early on, I struggled to learn Miva Merchant and being self-employed there was no one to turn to but the forums. Bill was always there to offer a solution and help me become a better programmer.
Bill epitomized the selfless sharing and community building found on this forum. Bill was always the first to share information and lend a helping hand. He was always supportive and never condescending. He helped build this community that has made Miva especially different than other carts.
With all the help that Bill gave, I too wanted to start giving back to this forum and assist others and started to post answers and solutions. I think Bill's helpfulness was infectious. I made many great personal friends from sharing on this forum.
After the basket:groups array came out in PR8 my QMIN module broke and hasn't been updated so I wrote some code that emulates the functionality of the QMIN module.
So in Bill's memory and I would like to share it.
Step 1. Create a Product Custom Field for quantity minimums
Utilities Settings > Custom Fields > Add >
Type: Product
Code: qmin
Name: Qmin
Field Type: Text
Step 2. Populate Product Qmin data
Products > Custom Fields > Qmin
The data is pipe separated with the data mask of minimum|step1,step2,step3,etc|maximum|. For example, if you sell a product in kits of 100 up to 500 then enter the data 100|100,200,300,400,500|500|. If there is no product minimum then just leave the field blank.
Step 3. Create a page template named Qmin for the quantity select box found on the PROD page.
User Interface > Pages > Add >
Name: Qmin
Description: Qmin quantity select box
Code:
<mvt:if expr="'PROD' CIN g.Screen"> <mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields:qmin"> <mvt:assign name="g.has_qmin" value="1" /> <mvt:assign name="g.qminimum" value="gettoken(l.settings:product:customfield_values:customfields:qmin, '|', 1)" /> <mvt:assign name="g.qsteps" value="gettoken(l.settings:product:customfield_values:customfields:qmin, '|', 2)" /> <mvt:assign name="g.qmaximum" value="gettoken(l.settings:product:customfield_values:customfields:qmin, '|', 3)" /> <mvt:if expr="NOT ISNULL g.qsteps"> <mvt:assign name="l.settings:qsteps" value="miva_array_serialize (g.qsteps)" /> <mvt:assign name="l.settings:qsteps_array" value="miva_array_deserialize( l.settings:qsteps )" /> <select name="Quantity"> <mvt:foreach iterator="qstep" array="qsteps_array"> <option value="&mvte:qstep;">&mvte:qstep;</option> </mvt:foreach> </select> <mvt:elseif expr="g.qminimum"> <input type="text" name="Quantity" value="&mvte:global:qminimum;" size="4"> <mvt:else> <input type="text" name="Quantity" value="1" size="4"> </mvt:if> <mvt:else> <input type="text" name="Quantity" value="1" size="4"> </mvt:if> <mvt:elseif expr="'BASK' CIN g.Screen"> <mvt:item name="customfields" param="Read_Product_Code( g.selected_code, 'qmin', g.qmin_customfield )" /> <mvt:if expr="NOT ISNULL g.qmin_customfield"> <mvt:assign name="g.has_qmin" value="1" /> <mvt:assign name="g.qminimum" value="gettoken(g.qmin_customfield, '|', 1)" /> <mvt:assign name="g.qsteps" value="gettoken(g.qmin_customfield, '|', 2)" /> <mvt:assign name="g.qmaximum" value="gettoken(g.qmin_customfield, '|', 3)" /> <mvt:if expr="NOT ISNULL g.qsteps"> <mvt:assign name="l.settings:qsteps" value="miva_array_serialize (g.qsteps)" /> <mvt:assign name="l.settings:qsteps_array" value="miva_array_deserialize( l.settings:qsteps )" /> <select name="Quantity"> <mvt:foreach iterator="qstep" array="qsteps_array"> <mvt:assign name="g.qstep_index" value="g.qstep_index + 1" /> <option value="&mvte:qstep;"<mvt:if expr="l.settings:qstep EQ g.selected_quantity"> selected</mvt:if>>&mvte:qstep;</option> </mvt:foreach> </select> <mvt:else> <input type="text" name="Quantity" size="4" value="&mvt:global:selected_quantity;" /> </mvt:if> <mvt:else> <input type="text" name="Quantity" size="4" value="&mvt:global:selected_quantity;" /> </mvt:if> <mvt:else> <input type="text" name="Quantity" value="1" size="4"> </mvt:if>
In the Product Display Tab select and add the custom field Qmin.
Step 4. Create a page template named PREACTION_QTYG
Code: PREACTION_QTYG
Description: Preaction on Basket page to error check Update Quantity form
Code:
<mvt:if expr="'QTYG' CIN g.Action"> <mvt:item name="customfields" param="Read_Product_Code( g.selected_code, 'qmin', g.qmin_customfield )" /> <mvt:else> <mvt:item name="customfields" param="Read_Product_Code( g.product_code, 'qmin', g.qmin_customfield )" /> </mvt:if> <mvt:if expr="NOT ISNULL g.qmin_customfield"> <mvt:assign name="g.has_qmin" value="1" /> <mvt:assign name="g.miva_separator" value="'|'" /> <mvt:assign name="g.qminimum" value="gettoken( g.qmin_customfield, g.miva_separator, 1 )" /> </mvt:if> <mvt:if expr="g.quantity LT g.qminimum"> <mvt:assign name="g.quantity" value="g.qminimum" /> <mvt:assign name="g.error_message_count" value="g.error_message_count + 1" /> <mvt:assign name="g.error_messages[1]" value="'This item has a minimum quantity.'" /> <mvt:assign name="g.formerror" value="1" /> </mvt:if>
Step 5: Update PROD template
This will insert the quantity minimum in the text box.
On the PROD > Product Display template find the form input for the quantity and replace with:
Code:
<div class="product-quantity"> <span>Quantity:</span><mvt:do name="l.result" file="g.Module_Feature_TUI_MGR" value="TemplateManager_Render_Page( 'QMIN' )" /> </div>
This will do a preaction on the update quantity form to make sure the user doesn't enter a quantity lower than the minimum.
On the BASK > Basket Contents tab:
Find the basket:groups array iterator and add just below:
Code:
<mvt:foreach iterator="group" array="basket:groups"> // <mvt:comment>Create global variables for QTYG Preaction quantity minimums</mvt:comment> <mvt:comment>Preaction checks and adjusts for quantity minimums in product:custom_fields:qmin</mvt:comment> <mvt:assign name="g.selected_quantity" value="l.settings:group:quantity" /> <mvt:assign name="g.selected_code" value="l.settings:group:code" />
Code:
<form method="post" action="&mvte:urls:BASK:auto;"> // <mvt:comment>Preaction checks and adjusts for quantity minimums in product:custom_fields:qmin</mvt:comment> <input type="hidden" name="PreAction" value="PREACTION_QTYG"> <input type="hidden" name="Action" value="QTYG"> <input type="hidden" name="selected_code" value="&mvte:group:code;">
Code:
// <mvt:comment>Screen checks and adjusts for quantity minimums in product:custom_fields:qmin</mvt:comment> <mvt:do name="l.result" file="g.Module_Feature_TUI_MGR" value="TemplateManager_Render_Page( 'QMIN' )" /> <button type="submit" class="">Update</button> </form>
This is custom code so may not work in every merchant store but you are welcome to try this code and fork it to your taste. This code is for technically minded merchants and may break your store. Future Miva updates may also break this code.
Note: I didn't have user privileges in the Community News section so I posted the memorium here.
Comment