Jump to content

Making Configfurable Options read only


Go to solution Solved by gavingwatson,

Recommended Posts

Hello,

I am trying to deeplink directly to the cart with some configurable options preset, which I am able to do successfully, all good. But what I need to achieve is that, by passing something in the URL, it makes the configurable options read only (so the customer cannot update them). The reason for this is that we are making some offers on our site which are available immediately (instant provisioning) but if they then alter anything on the cart, the *may* think that it is still instantly provisioned, it it will no longer be.

My solution to this, according to WHMCS support, would be to pass an additional option in the URL (such as &readonly=1 or similar) and pick that up in configureproduct.tpl with an if statement to make the Configurable Options read-only.

My question is, where in the following code would I add the code for that?

 {if $configoption.optiontype eq 1}
                                        <div class="col-sm-6">
                                            <div class="form-group">
                                                <label for="inputConfigOption{$configoption.id}">{$configoption.optionname}</label>
                                                <select name="configoption[{$configoption.id}]" id="inputConfigOption{$configoption.id}" class="form-control">
                                                    {foreach key=num2 item=options from=$configoption.options}
                                                        <option value="{$options.id}"{if $configoption.selectedvalue eq $options.id} selected="selected"{/if}>
                                                            {$options.name}
                                                        </option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>

If it were pure PHP I could work it out, along the lines of (for example):

$readonly = $_GET['readonly'];
if ($readonly == "1")
{
echo '
<option value="{$options.id}"{if $configoption.selectedvalue eq $options.id} selected="selected" readonly{/if}>
                                                            {$options.name}
                                                        </option>';
}
else
{
echo '<option value="{$options.id}"{if $configoption.selectedvalue eq $options.id} selected="selected"{/if}>
                                                            {$options.name}
                                                        </option>';
}

(Sorry, can't convert that to code for some reason).

So my question is, in the .tpl file, how would I pick up the variable in the URL and add that logic?

Thanks in advance.

 

Link to comment
Share on other sites

  • Solution

I actually figured that out by using this:

<div class="col-sm-6">
                                            <div class="form-group">
                                                <label for="inputConfigOption{$configoption.id}">{$configoption.optionname}</label>
                                                <select name="configoption[{$configoption.id}]" id="inputConfigOption{$configoption.id}" class="form-control" {if $productinfo.pid eq 21} disabled=""}{/if}{if $productinfo.pid eq 65} disabled=""}{/if}>
                                                    {foreach key=num2 item=options from=$configoption.options}
                                                        <option value="{$options.id}"{if $configoption.selectedvalue eq $options.id} selected="selected" {/if}>
                                                            {$options.name}
                                                        </option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>

 

(I added this part

 {if $productinfo.pid eq 21} disabled=""}{/if}{if $productinfo.pid eq 65} disabled=""}{/if}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated