Forum Replies Created

Viewing 5 replies - 16 through 20 (of 20 total)
  • Thread Starter Evan

    (@skysarwer)

    Just to add more info that may be of interest, here is a list of funcitonalities I have set up with the template customizations:

    • Adding default add-on options to individual products by checking if the product contains an attribute whose slug matches the value title and type id of an add on group item
    • Custom ids to add extra functionality to specific add on groups (such as disabling one group unless an option in a different group is selected
    • Pulling data such as images and descriptions from custom fields from the attributes associated with the add-on groups
    • Disabling add-on options if a custom field is set to disabled on the associated attribute

    I also customized the display of the groups in the type.php and checkbox-type.php templates to make the drop-downs based in HTML and CSS.

    Thread Starter Evan

    (@skysarwer)

    Hello Bizswoop team!

    Thank you for your reply, and sorry for my delay in replying.

    To clarify your first question, I was referring to the sort of front-end options (https://ibb.co/r4K2F8N) — there are currently workarounds in your plugin to adequately sort the rows and etc I find ??

    For the second question, I was referring to the templates for the plugin located in the plugin folder/includes/frontend/templates

    I have made all sorts of customization for all of the templates in that folder (adding custom class and ID names to the rows and options, connecting the options and rows with WC attributes and pulling custom fields from them, etc…)

    I was wondering if there is any way to override these template files in the installed theme instead, since currently I have to backup and re-upload the files each time the plugin upgrades. I saw that you recently released a new update so I will have to do that soon as well.

    For some sample code, I’ll quote the code in my customzied template file for radio.php at the end of this post.

    Thanks again for your engaged response to my question and the amazing plugin which I greatly enjoy! Best regards

    <?php 
    $attGroup = "pa_".clean($group->title); // assign WC product attribute prefix to each group name 
    
    $terms = get_the_terms( $product->id, strtolower($attGroup));
    
    $allTerms = get_terms(strtolower($attGroup), array ('hide_empty'=>false));
    
     if (is_array($terms) || is_object($terms)) {
     foreach($terms as $term){
             $termName = $term->slug; 
     }}
    foreach ($type->values as $id => $value) {
        $groupTitle = clean($type->title);
        $valueTitle = clean($value->title);
        $valueId = strtolower($valueTitle)."-".$type->getID();
        if ($value->hide) {
            continue;
        }?>
    	<div class="zaddon_radio">
    		<label>
    			<input
    			    <?php 
    			   
    			    foreach ($allTerms as $all) { 
    			         $termtags = get_field('tag', $all);
    			        if($all->slug ==  $valueId) 
    			        { if (get_field('unavailable', $all)){
    			            echo 'disabled';
    			            }  
    			            else if ($termtags) {
    			                 foreach($termtags as $termtag) {if (get_field('unavailable', $termtag)) {
    			                    echo 'disabled';
    			                }}
    			            }
    			           }
    			          }?>
    				type="radio"
    				<?php if ($id === 0 && $type->required) { ?>required<?php } ?>
    				
    				
    				<?php
    				if ($termName ==  $valueId) {
    				    echo 'checked';
    				}
    				?>
    				id="<?=$type->getID(); ?>-<?php echo $valueTitle;?>"
    				name="<?= $name ?>[value]"
    				class="addon-input"
    				value="<?= $value->getID() ?>"
    				data-price="<?= $value->price ?>"
    				data-type="<?= $type->type ?>"
    				<?php if($type->getID() == "8") {
    				    echo 'onclick="stoneCheck();"';
    				    } 
    				    if ($type->getID() == "12") {
    				        echo 'onclick="layerCheck();"';
    				    }
    				    ?>
    			/> 
    			<?= $value->title ?>
    			<?= $value->price ? '(+' . wc_price($value->price) . ')' : "" ?>
                <?= !$value->hide_description ? '<p class="zaddon-option-description">' .$value->description. '</p>': "" ?>
            </label><span><?php foreach ($allTerms as $all) { if($all->slug ==  $valueId) { if (get_field('image', $all) || get_field('tag', $all)) {echo '&nbsp;<span class="example-hover"> <span class="q">?</span><div class="example-cont">';
            if (get_field('image', $all)) { 
                echo '<img class="example-image" src="'.get_field('image', $all).'">';
            }
            $termtags = get_field('tag', $all);
    			if ($termtags) {
    			    foreach($termtags as $termtag) { echo '<p>'.$termtag->description;} 
    			echo '<br><br><a href="/index/'.$termtag->slug.'" target="_blank">Learn More</a></p>'; }
                echo '</div></span>';
            }
    			//$termtags = get_field('tag', $all);
    			//if ($termtags) {foreach($termtags as $termtag) {echo $termtag->description;}}
    			}} ?>
           
    	</div>
    <?php } ?>
    Thread Starter Evan

    (@skysarwer)

    If I may add another note: I think the best thing to prioritize would be enabling the user to change the order of the type values (the labels, or individual options). Right now if the user adds a new option and wants it in the middle of their existing Group or row, they have to rewrite all the options from scratch.

    Thread Starter Evan

    (@skysarwer)

    Hey! Thanks for your reply!

    I ended finding a solution suitable to my needs, very similar to what you laid out. I went into the frontend files and generated IDs and Classes based on the Group and Value titles and IDs – allowed a lot of new functionality that solved my issues.

    I will write a comprehensive report on what I did in a new post, after I tweak it a little ?? Thank you!

    Thread Starter Evan

    (@skysarwer)

    Thank you very much for the reply!

    Yes I can see how this use case would be seen as a customization request. I am working on finding a solution independently and am happy to share more details.

    If there is a simple way to have the html code for the product groups generated inside the single-content-product template or something it would enable the adding of unique classes and IDs to the input and label fields, which the user can then add their own CSS and JS logic to.

    Of particular interest, this can allow users to assign different default values for different products that use the same fields, disabling and enabling fields based on the status of other inputs, and a lot more that I can see having wide appeal as features.

    I have tried to implement a solution you can see here (the “chest center” and “precious stone” field and values give a good example of newly introduced logic), by copying the html that the plugin generated, pasting it into my page template, then setting the display of the original html to none. It works on the client side, however the fields do not validate or carry over now to the cart or checkout page.

    I am trying to read through the product.php file and the templates in the frontend directory to see how I might enable them to be validated like the originally generated fields, but am not having success applying the rules to validate the fields on checkout.

    If there is a quick solution you can see from your perspective – it would be hugely appreciated and unlock a ton of potential that this plugin can have. Even just pointing me in the right direction would be a huge help – I’ll be sure to come back on here to share if I find a solution of course ??

    Thank you very much!
    Evan

    • This reply was modified 5 years, 2 months ago by Evan.
Viewing 5 replies - 16 through 20 (of 20 total)