Unable to keep track of my registration quatities

newbienewbie Member
Hi guys, I'm a newbie to foxycart & full disclosure, I'm a novice coder trying to see if I can get done the simple things we need on our website.

I'm having trouble keeping track of the quantities of my "registration fees."

For instance, if you go to: https://www.clean-simpletx.com/our-packages-paytrace
and select the payment plan of "monthly" under Standard Package, then "yes" to the delicates option. You're properly charged a registration fee.

If you then, immediately just toggle the delicates option to "no" (leaving payment plan at "monthly") and select add to cart again, the registration fee that should be added gets lost.

I'm missing something, but for the life of me don't know what... Any help would be sincerely appreciated...

Thanks,
Francie

------------------------------------------------------------------------------------------------------------------------------------------
<!-- form -->
<form action="https://clean-simple.foxycart.com/cart" method="post" accept-charset="utf-8">

<input type="hidden" name="name" value="Membership" />
<input type="hidden" name="code" value="Standard" />
<input type="hidden" name="price" value="39" />

<select onchange="yesnoCheck(this);" name="sub_frequency" required>

<option value="" selected>Select Payment Plan</option>
<option value="">One-Time ($39, $25 registration)</option>
<option value="1m{p:139|c+_Monthly}">Monthly ($139/mo, $25 registration)</option>
<option value="6m{p:834|c+_5%Off}">6 Mos ($834/6mo, save 5% + $0 regis!)</option>
<option value="1y{p:1668|c+_10%off}">Yearly ($1,668/yr, save 10% + $0 regis!)</option>

</select>

<input type="hidden" name="2:name" value="Registration Fee" />
<input type="hidden" name="2:code" value="Regis_Fee" />
<input type="hidden" name="2:price" value="25" />
<input type="hidden" name="2:parent_code" value="Standard" />
<input type="hidden" name="2:quantity_min" value="1" />
<input type="hidden" name="2:quantity_max" value="999" />

<br />

<!-- Define the Delicates Bag option -->
<div id="ifYes" style="display: none;">

<select name="Delicates_Bag" required>
<option value="" selected>Add a Delicates bag?</option>
<option value="Yes (+$5){p+5}">Yes (+ $5)</option>
<option value="No">No</option>
</select>

</div>

<script>

function yesnoCheck(that)
{ <!-- Delicates bag option -->
if (that.value !== 0)
{
document.getElementById("ifYes").style.display = "block";
}
else
{
document.getElementById("ifYes").style.display = "none";
}

<!-- Check if 6m or Y plan was selected -->
if (that.value == "6m{p:834|c+_5%Off}" || that.value == "1y{p:1668|c+_10%off}")
{

<!-- If so, set Registration to Free -->
document.getElementsByName("2:name")[0].setAttribute("value","Free Registration ($0)");
document.getElementsByName("2:code")[0].setAttribute("value","Early Plan");
document.getElementsByName("2:price")[0].setAttribute("value","0");
}
else
{
<!-- If not, set Registration to $25 -->
document.getElementsByName("2:price")[0].setAttribute("value",25);
}
}

</script>

<br />

<div>
<button type="submit">Add to Cart</button>
</div>

</form>
Comments
  • fc_adamfc_adam FoxyCart Team
    edited October 13
    @newbie,

    Welcome! Thanks for the detailed post and link to your page, that's super helpful for us - I can see what you're describing there.

    The issue you're seeing relates to the bundled products - and that the registration fee is locked to the parent product. When a child product is locked to the parent, it is unable to be removed individually and it's quantity is also matched to the quantity of the parent it's linked with.

    When the monthly sub with delicates selected is added to the cart, that is adding that bundled product to the cart. The parent product has a code of "Standard_monthly", and that's the code the child product is matching to. When you then deselect the delicates option and add it again - it's again adding a bundle, but the parent product is changed as it is missing the delicates option, so that's added as a separate product to the first one. The child product is still linked to "Standard_monthly" though as it's parent product - and as there are two products with that code, it's linking with the first one (the one that was added previously). As the child product is locked to the parent, it's matching it's quantity and so staying at 1.

    To fix it - you can set the delicates product option to also affect the code. For example, if you update your delicates option like this - that should get it adding the registration fee to both instances of the product:
    <select name="Delicates_Bag" required="" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected="">Add a Delicates bag?</option>
    <option value="Yes (+$5){p+5|c+_delicates}">Yes (+ $5)</option>
    <option value="No">No</option>
    </select>
  • Thanks so much for the detailed explanation and fix! Works like a charm!!
  • Hey Adam, thanks for all your help the last few days! Slowly but surely I'm getting there.

    I've managed to lose track of my registration child products with the code I'm currently using & I'm not sure how to fix it.

    here's the site link https://clean-simpletx.com/our-packages-paytrace & code below.

    If you select "Magnific inline popup" then add "Essentials," "One-Time" to the cart, then add "Standard", "One-Time" to the cart, I lose a child Registration product that I'm wanting to be there. Not sure what's happening...

    Grateful for your time,
    Francine

    <a href="#form-popup" class="open-popup-link">Magnific inline popup</a>

    <!-- Popup -->
    <div id="form-popup" class="white-popup mfp-hide">
    <!-- form -->
    <form action="https://clean-simple.foxycart.com/cart" method="post" accept-charset="utf-8">
    <h2>Membership Form</h2>
    <select onchange="yesnoCheck(this);" name="name" required >
    <!-- Select a Laundry Package -->
    <option value="" selected>Select a Laundry Package</option>
    <option value="Essentials_Membership">Essentials (20lbs)</option>
    <option value="Standard_Membership">Standard (30lbs)</option>
    <option value="Plus_Membership">Plus (40lbs)</option>
    <option value="Premium_Membership">Premium (50lbs)</option>
    </select>

    <input type="hidden" name="code" value="L"/>
    <input type="hidden" name="price" value="" />
    <input type="hidden" name="category" value="Regular"/>

    <input type="hidden" name="2:name" value="Registration" />
    <input type="hidden" name="2:code" value="Regis" />
    <input type="hidden" name="2:price" value="25" />
    <input type="hidden" name="2:parent_code" value="L" />
    <input type="hidden" name="2:quantity_min" value="1" />
    <input type="hidden" name="2:quantity_max" value="999" />


    <br />

    <div id="ifYesEssentials" style="display: none;">
    <!-- Display Essentials Pricing Dropdown -->
    <select name="" class="sub_frequency" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected>Select Payment Plan</option>
    <option value="">One-Time ($29, $25 registration)</option>
    <option value="1m{p:98|c+_Es_Mo}">Monthly ($98/mo, $25 registration)</option>
    <option value="6m{p:588|c+_Es_5%Off|y:6mos}">6 Mos ($588/6mo, save 5% + $0 regis!)</option>
    <option value="1y{p:1176|c+_Es_10%off|y:Year}">Yearly ($1,176/yr, save 10% + $0 regis!)</option>
    </select>
    </div>

    <div id="ifYesStandard" style="display: none;">
    <!-- Display Standard Pricing Dropdown -->
    <select name="" class="sub_frequency" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected>Select Payment Plan</option>
    <option value="">One-Time ($39, $25 registration)</option>
    <option value="1m{p:139|c+_St_Mo}">Monthly ($139/mo, $25 registration)</option>
    <option value="6m{p:834|c+_St_5%Off|y:6mos}">6 Mos ($834/6mo, save 5% + $0 regis!)</option>
    <option value="1y{p:1668|c+_St_10%off|y:Year}">Yearly ($1,668/yr, save 10% + $0 regis!)</option>
    </select>
    </div>

    <div id="ifYesPlus" style="display: none;">
    <!-- Display Plus Pricing Dropdown -->
    <select name="" class="sub_frequency" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected>Select Payment Plan</option>
    <option value="">One-Time ($49, $25 registration)</option>
    <option value="1m{p:178|c+_Pl_Mo}">Monthly ($178/mo, $25 registration)</option>
    <option value="6m{p:1068|c+_Pl_5%Off|y:6mos}">6 Mos ($1,068/6mo, save 5% + $0 regis!)</option>
    <option value="1y{p:2136|c+_Pl_10%off|y:Year}">Yearly ($2,136/yr, save 10% + $0 regis!)</option>
    </select>
    </div>

    <div id="ifYesPremium" style="display: none;">
    <!-- Display Premium Pricing Dropdown -->
    <select name="" class="sub_frequency" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected>Select Payment Plan</option>
    <option value="">One-Time ($59, $25 registration)</option>
    <option value="1m{p:212|c+_Pm_Mo}">Monthly ($212/mo, $25 registration)</option>
    <option value="6m{p:1272|c+_Pm_5%Off|y:6mos}">6 Mos ($1,272/6mo, save 5% + $0 regis!)</option>
    <option value="1y{p:2544|c+_Pm_10%off|y:Year}">Yearly ($2,544/yr, save 10% + $0 regis!)</option>
    </select>
    </div>

    <div id="ifYesDayBags" style="display: none;">
    <!-- Define Pick-up Day option -->
    <select name="Pickup_Day" required="" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected="">Select a Laundry Pickup Day?</option>
    <option value="Tues 8am{c+_tu}">Tues 8am</option>
    <option value="Thurs 8am{c+_th}">Thurs 8am</option>
    </select>

    <!-- Define the Delicates Bag option -->
    <select name="Delicates_Bag" required="" id="yui_3_17_2_1_1507857198588_459">
    <option value="" selected="">Add a Delicates bag?</option>
    <option value="Yes (+$5){p+5|c+_del}">Yes (+ $5)</option>
    <option value="No">No</option>
    </select>
    </div>
    <br />

    <script>
    function yesnoCheck(that) {
    // Display next dropdowns
    if (that.value == "Essentials_Membership") {
    document.getElementsByName("price")[0].setAttribute("value",29);
    switchMembership("ifYesEssentials");
    }
    else if (that.value == "Standard_Membership") {
    document.getElementsByName("price")[0].setAttribute("value",39);
    switchMembership("ifYesStandard");
    }
    else if (that.value == "Plus_Membership") {
    document.getElementsByName("price")[0].setAttribute("value",49);
    switchMembership("ifYesPlus");
    }
    else {
    document.getElementsByName("price")[0].setAttribute("value",59);
    switchMembership("ifYesPremium");
    }
    document.getElementById("ifYesDayBags").style.display = "block";
    }

    function switchMembership(type) {
    console.log(type);
    var selects = document.querySelectorAll(".sub_frequency");
    for (var i = 0; i < selects.length; i++) {
    selects[i].removeAttribute("required");
    selects[i].setAttribute("name", "");
    selects[i].parentNode.style.display = "none";
    }
    var parent = document.getElementById(type);
    parent.style.display = "block";
    var select = parent.querySelectorAll("select")[0];
    select.setAttribute("name", "sub_frequency");
    select.required = true;
    }
    </script>

    <div>
    <button type="submit">Add to Cart</button>
    </div>
    </form>
    </div>


  • fc_adamfc_adam FoxyCart Team
    @newbie,

    I had some trouble with getting your magnific modal to show up - but was able to get the form working in a round about way to test your scenario there.

    I believe the issue is similar to what you bumped into earlier - that both of those products share the same category value. You could try updating your yesnoCheck() function like this:
    function yesnoCheck(that) {
    // Display next dropdowns
    if (that.value == "Essentials_Membership") {
    document.getElementsByName("price")[0].setAttribute("value",29);
    document.getElementsByName("category")[0].setAttribute("value","L_Es");
    switchMembership("ifYesEssentials");
    }
    else if (that.value == "Standard_Membership") {
    document.getElementsByName("price")[0].setAttribute("value",39);
    document.getElementsByName("category")[0].setAttribute("value","L_St");
    switchMembership("ifYesStandard");
    }
    else if (that.value == "Plus_Membership") {
    document.getElementsByName("price")[0].setAttribute("value",49);
    document.getElementsByName("category")[0].setAttribute("value","L_Pl");
    switchMembership("ifYesPlus");
    }
    else {
    document.getElementsByName("price")[0].setAttribute("value",59);
    document.getElementsByName("category")[0].setAttribute("value","L_Pm");
    switchMembership("ifYesPremium");
    }
    document.getElementById("ifYesDayBags").style.display = "block";
    }
    You'll also then want to update your dropdowns to remove the first part of the code modification, so for example where you have this:
    <option value="1m{p:98|c+_Es_Mo}">Monthly ($98/mo, $25 registration)</option>
    Would become this:
    <option value="1m{p:98|c+_Mo}">Monthly ($98/mo, $25 registration)</option>
    I believe that should get it correctly tracking each bundled registration fee again.
  • Sorry, I had modified the magnific modal... I integrated your feedback and got it working! Thank you!
Sign In or Register to comment.