コード例 #1
0
 public function vtmin_ajax_edit_product($product_ID)
 {
     global $wpdb, $post, $vtmin_rule, $vtmin_setup_options;
     //edits copied from vtmin-rules-update.php
     if ($product_ID == ' ') {
         $vtmin_rule->rule_error_message[] = __('No Product ID was supplied.', 'vtmin');
         return;
     }
     if (is_numeric($product_ID) === false) {
         $vtmin_rule->rule_error_message[] = __('Product ID was not numeric. ', 'vtmin');
         if ($vtmin_setup_options['debugging_mode_on'] == 'yes') {
             $vtmin_rule->rule_error_message[0] .= '<br><br>Product ID in error = <span id="varProdID-error-ID">' . $product_ID . '</span>';
         }
         return;
     }
     $test_post = get_post($product_ID);
     if (!$test_post) {
         $vtmin_rule->rule_error_message[] = __('Product ID was not found', 'vtmin');
         if ($vtmin_setup_options['debugging_mode_on'] == 'yes') {
             $vtmin_rule->rule_error_message[0] .= '<br><br>Product ID in error = <span id="varProdID-error-ID">' . $product_ID . '</span>';
         }
         return;
     }
     $vtmin_rule->inpop_varProdID_name = $test_post->post_title;
     $product_has_variations = vtmin_test_for_variations($product_ID);
     if ($product_has_variations == 'no') {
         $vtmin_rule->rule_error_message[] = __('Product has no Variations. Product Name = ', 'vtmin') . $vtmin_rule->inpop_varProdID_name . __('<br><br> Please use "Single Product Only" option, above.', 'vtmin');
         if ($vtmin_setup_options['debugging_mode_on'] == 'yes') {
             $vtmin_rule->rule_error_message[0] .= '<br><br>Product ID in error = <span id="varProdID-error-ID">' . $product_ID . '</span>';
         }
         return;
     }
     $product_variation_IDs = vtmin_get_variations_list($product_ID);
     if ($product_variation_IDs <= ' ') {
         $vtmin_rule->rule_error_message[] = __('Product has no Variations. Product Name = ', 'vtmin') . $vtmin_rule->inpop_varProdID_name . __('<br><br> Please use "Single Product Only" option, above.', 'vtmin');
         if ($vtmin_setup_options['debugging_mode_on'] == 'yes') {
             $vtmin_rule->rule_error_message[0] .= '<br><br>Product ID in error = <span id="varProdID-error-ID">' . $product_ID . '</span>';
         }
         return;
     }
     return $product_variation_IDs;
 }
コード例 #2
0
    public function vtmin_pop_in_select()
    {
        global $post, $vtmin_info, $vtmin_rule;
        $vtmin_rules_set;
        $checked = 'checked="checked"';
        $vtminNonce = wp_create_nonce("vtmin-rule-nonce");
        //nonce verified in vt-minimum-purchase.php
        $disabled = 'disabled="disabled"';
        ?>
         
        <style type="text/css">
           /*Free version*/
           #cartChoice,
           #cartChoice-label,
           #varChoice,
           #varChoice-label,
           #singleChoice,
           #singleChoice-label,
           #prodcat-in,
           #prodcat-in h3,
           .and-or,
           #rulecat-in,
           #rulecat-in h3,
           #andChoice-label         
           {color:#aaa;}  /*grey out unavailable choices*/
           #wpsc_product_category-adder,
           #vtmin_rule_category-adder {
            display:none;
           }
           #vtmin-pop-in-cntl {margin-bottom:15px;}
           /*v1.06 begin*/
           .pro-anchor {
              border: 1px solid #CCCCCC;
              clear: both;
              color: #000000;
              float: left;
              font-size: 14px;
              margin-bottom: 10px;
              margin-left: 2%;
              margin-top: 20px;
              padding: 5px 10px;
              text-decoration: none;
              width: auto;        
           }
           #inpopDescrip-more-help {color: #0074A2 !important;font-size: 15px;}
           /*v1.06 end*/
        </style>
                   
        <input type="hidden" id="vtmin_nonce" name="vtmin_nonce" value="<?php 
        echo $vtminNonce;
        ?>
" />
        
        <input type="hidden" id="fullMsg" name="fullMsg" value="<?php 
        echo $vtmin_info['default_full_msg'];
        ?>
" />  <?php 
        //v1.08
        ?>
                            
        <div class="column1" id="inpopDescrip">
            <h4> <?php 
        _e('Choose how to look at the Candidate Population', 'vtmin');
        ?>
</h4>
            <p> <?php 
        _e('Minimum Amount rules will only look at the contents of the cart at checkout.
            Minimum Amount rules define a candidate group within the cart. The Free version of the plugin
            applies only to logged-in user membership status.', 'vtmin');
        ?>
           
            </p>
            <?php 
        //v1.06 msg moved below
        ?>
        </div>

        
        <div class="column2" id="inpopChoice">       
          <h3><?php 
        _e('Select Search Type', 'vtmin');
        ?>
</h3>
          <div id="inpopRadio">
          <?php 
        $sizeof_rule_inpop = sizeof($vtmin_rule->inpop);
        for ($i = 0; $i < $sizeof_rule_inpop; $i++) {
            ?>
                 
              
              <input id="<?php 
            echo $vtmin_rule->inpop[$i]['id'];
            ?>
" class="<?php 
            echo $vtmin_rule->inpop[$i]['class'];
            ?>
" type="<?php 
            echo $vtmin_rule->inpop[$i]['type'];
            ?>
" name="<?php 
            echo $vtmin_rule->inpop[$i]['name'];
            ?>
" value="<?php 
            echo $vtmin_rule->inpop[$i]['value'];
            ?>
" <?php 
            if ($vtmin_rule->inpop[$i]['user_input'] > ' ') {
                echo $checked;
            } else {
                echo $disabled;
            }
            ?>
 /><span id="<?php 
            echo $vtmin_rule->inpop[$i]['id'] . '-label';
            ?>
"> <?php 
            echo $vtmin_rule->inpop[$i]['label'];
            ?>
</span><br />

           <?php 
        }
        ?>
                 
          </div>

          <span class="" id="singleChoice-span">                                  
            <span id="inpop-singleProdID-label"><?php 
        _e('&nbsp; Enter Product ID Number', 'vtmin');
        ?>
</span><br />                    
             <input id="<?php 
        echo $vtmin_rule->inpop_singleProdID['id'];
        ?>
" class="<?php 
        echo $vtmin_rule->inpop_singleProdID['class'];
        ?>
" type="<?php 
        echo $vtmin_rule->inpop_singleProdID['type'];
        ?>
" name="<?php 
        echo $vtmin_rule->inpop_singleProdID['name'];
        ?>
" value="<?php 
        echo $vtmin_rule->inpop_singleProdID['value'];
        ?>
">
             <br /> 
            <?php 
        if ($vtmin_rule->inpop_singleProdID['value'] > ' ') {
            ?>
           
                <span id="inpop-singleProdID-name-label"><?php 
            _e('&nbsp; Product Name', 'vtmin');
            ?>
</span><br /> 
                <span id="inpop-singleProdID-name" ><?php 
            echo $vtmin_rule->inpop_singleProdID_name;
            ?>
</span><br />
            <?php 
        }
        ?>
                                         
          </span>
          
        </div>
         
        <div class="column3 inpopExplanation" id="cartChoice-chosen">
            <h4><?php 
        _e('Apply to all products in the cart', 'vtmin');
        ?>
<span> - <?php 
        _e('explained', 'vtmin');
        ?>
</span></h4>
            <p><?php 
        _e('No threshhold group is chosen, and the initial rule logic applies to all products
            to be found in the cart.', 'vtmin');
        ?>
              
            </p>
        </div>
        <div class="column3 inpopExplanation" id="groupChoice-chosen">
            <h4><?php 
        _e('Use Selection Groups', 'vtmin');
        ?>
<span> - <?php 
        _e('explained', 'vtmin');
        ?>
</span></h4> 
            <p><?php 
        _e('Using selection groups, you can specify the initial focus of the rule, focusing on some products found in the cart.  
            A selection group can be considered a threshhold, which when reached the other
            aspects of the rule is applied.  For example, if you specify category Auto Parts, then
            if products in categories other than Auto Parts are in the cart, the rule would not apply to them.', 'vtmin');
        ?>
           
            </p>
          </div>
        <div class="column3 inpopExplanation" id="varChoice-chosen">
            <h4><?php 
        _e('Single Product with Variations', 'vtmin');
        ?>
<span> - <?php 
        _e('explained', 'vtmin');
        ?>
</span></h4>
            <p><?php 
        _e('Apply rule to the variations for a single product found in the cart, whose ID is supplied in the "Product ID" box.  Enter the Product ID and hit the "Product and Variations" button (The product ID can be found in the URL
            of the product during a product edit session).  Select any/all of the variations belonging to the product.', 'vtmin');
        ?>
           
            </p>
        </div>  
        <div class="column3 inpopExplanation" id="singleChoice-chosen">
            <h4><?php 
        _e('Single Product Only', 'vtmin');
        ?>
<span> - <?php 
        _e('explained', 'vtmin');
        ?>
</span></h4>
            <p><?php 
        _e('Only apply rule to a single product found in the cart, whose ID is supplied in the "Product ID" box.  The product ID can be found in the URL
            of the product during a product edit session.', 'vtmin');
        ?>
  
            <br /> <br /> 
            <?php 
        _e('For example, in the product edit session url:', 'vtmin');
        ?>
 
            <br /><br />  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <?php 
        _e('http://www.xxxx.com/wp-admin/post.php?post=872&action=edit', 'vtmin');
        ?>
 
            <br /><br />
            <?php 
        _e('The product id is in the "post=872" portion of the address, and hence the number is 872. You would enter 
            that number in the box to the left labeled "Enter Product ID Number".', 'vtmin');
        ?>
            <br /><br />
            <?php 
        _e('NB: If **single** is chosen, the value of "All" is applied to the Rule Application Method, regardless of what is chosen below.', 'vtmin');
        ?>
 
           </p>
        </div>        

        <div id="inpop-varProdID-cntl">            
          <a id="inpop-varProdID-more" class="help-anchor" href="javascript:void(0);">Single Product with Variations - <span id="pop-in-more-help">More Info</span></a>
         <p id="inpop-varProdID-descrip" class="help-text"><?php 
        _e('When "Single Product with Variations" is chosen, at least one variation must be selected.
         <br><br> NB - PLEASE NOTE: If the product variation structure is changed in any way, you MUST return to the matching rule and reselect your variation choices.
         <br><br>Multiple rules may be created to apply to individual variations, or groups of variations within a product.           
         <br><br>Please be sure to prevent any rule overlap when applied to a given
            product-variation combination.  An overlap example: if there is a category-level rule covering an entire product, and an individual rule applying to any of the product variations.
         <br><br>Rule overlap in variation rules is Not removed by the rule processing engine, it must be prevented here.', 'vtmin');
        ?>
             
         </p> 
          <div id="inpopVarBox">
              <h3>Single Product with Variations</h3>
              <div id="inpopVarProduct">
                <span id="inpop-varProdID-label"><?php 
        _e('&nbsp; Enter Product ID Number', 'vtmin');
        ?>
</span><br />                    
                 <input id="<?php 
        echo $vtmin_rule->inpop_varProdID['id'];
        ?>
" class="<?php 
        echo $vtmin_rule->inpop_varProdID['class'];
        ?>
" type="<?php 
        echo $vtmin_rule->inpop_varProdID['type'];
        ?>
" name="<?php 
        echo $vtmin_rule->inpop_varProdID['name'];
        ?>
" value="<?php 
        echo $vtmin_rule->inpop_varProdID['value'];
        ?>
">
                 <br />                            
              </div>
              <div id="inpopVarButton">
                 <?php 
        $product_ID = $vtmin_rule->inpop_varProdID['value'];
        $product_variation_IDs = vtmin_get_variations_list($product_ID);
        /* ************************************************
         **   Get Variations Button for Rule screen
         *     ==>>> get the product id from $_REQUEST['varProdID'];  in the receiving ajax routine. 
         ************************************************ */
        ?>
                                                        
                 <div class="inpopVar-loading-animation">
										<img title="Loading" alt="Loading" src="<?php 
        echo VTMIN_URL;
        ?>
/admin/images/indicator.gif" />
										<?php 
        _e('Getting Variations ...', 'vtmin');
        ?>
								 </div>
                 
                 
                 <a id="ajaxVariationIn" href="javascript:void(0);">
                    <?php 
        if ($product_ID > ' ') {
            ?>
                      <?php 
            _e('Refresh Variations', 'vtmin');
            ?>
                      
                    <?php 
        } else {
            ?>
                      <?php 
            _e('Get Variations', 'vtmin');
            ?>
 
                    <?php 
        }
        ?>
                  </a>
                 
              </div>
          </div>
          <div id="variations-in">
          <?php 
        if ($product_variation_IDs) {
            //if product still has variations, expose them here
            ?>
              <h3><?php 
            _e('Product Variations', 'vtmin');
            ?>
</h3>                  
            <?php 
            //********************************
            $this->vtmin_post_category_meta_box($post, array('args' => array('taxonomy' => 'variations', 'tax_class' => 'var-in', 'checked_list' => $vtmin_rule->var_in_checked, 'product_ID' => $product_ID, 'product_variation_IDs' => $product_variation_IDs)));
            // ********************************
        }
        ?>
           </div>  <?php 
        php;
        ?>
        </div>  <?php 
        //end inpopVarProdID
        ?>
       

        
        <?php 
        //v1.06 moved here, changed msg
        ?>
        <a id="" class="pro-anchor" target="_blank"  href="<?php 
        echo VTMIN_PURCHASE_PRO_VERSION_BY_PARENT;
        ?>
">( Greyed-out Options are available in the <span id="inpopDescrip-more-help">Pro Version</span> &nbsp;)</a>
         

       <div class="<?php 
        //echo $groupPop_vis
        ?>
 " id="vtmin-pop-in-cntl">                                                  
         <a id="pop-in-more" class="help-anchor" href="javascript:void(0);">Selection Groups - <span id="pop-in-more-help">More Info</span></a>
         <p id="pop-in-descrip" class="help-text"><?php 
        _e("Role/Membership is used within Wordpress to control access and capabilities, when a role is given to a user.  \r\n         Wordpress assigns certain roles by default such as Subscriber for new users or Administrator for the site's owner. Roles can also be used to associate a user \r\n         with a pricing level.  Use a role management plugin like http://wordpress.org/extend/plugins/user-role-editor/ to establish custom roles, which you can give \r\n         to a user or class of users.  Then you can associate that role with a Minimum Purchase Rule.  So when the user logs into your site, their Role interacts with the appropriate Rule.\r\n         <br><br>\r\n         In the Pro version, you may use an existing category to identify the group of products to which you wish to apply the rule.  \r\n         If you'd rather, use a Minimum Purchase Category to identify products - this avoids disturbing the store categories. Just add a Minimum Purchase Category, go to the product screen,\r\n         and add the product to the correct minimum purchase category.  (On your product add/update screen, the Mininimum purchase \r\n         category metabox is just below the default product category box.)  You can also apply the rule using User Membership or Roles  \r\n         as a solo selection, or you can use any combination of all three.  \r\n         <br><br>\r\n         Please take note of the relationship choice 'and/or'\r\n         when using roles.  The default is 'or', while choosing 'and' requires that both a role and a category be selected, before a rule\r\n         can be published.", 'vtmin');
        ?>
         </p> 
    
        <div id="prodcat-in">
          <h3><?php 
        _e('Product Categories', 'vtmin');
        ?>
</h3>
          
          <?php 
        // ********************************
        $this->vtmin_post_category_meta_box($post, array('args' => array('taxonomy' => $vtmin_info['parent_plugin_taxonomy'], 'tax_class' => 'prodcat-in', 'checked_list' => $vtmin_rule->prodcat_in_checked)));
        // ********************************
        ?>
        
        </div>  <?php 
        php;
        ?>
        <h4 class="and-or"><?php 
        _e('Or', 'vtmin');
        ?>
</h4>
        <div id="rulecat-in">
          <h3><?php 
        _e('Minimum Purchase Categories', 'vtmin');
        ?>
</h3>
          
          <?php 
        // ********************************
        $this->vtmin_post_category_meta_box($post, array('args' => array('taxonomy' => $vtmin_info['rulecat_taxonomy'], 'tax_class' => 'rulecat-in', 'checked_list' => $vtmin_rule->rulecat_in_checked)));
        // ********************************
        ?>
 
                         
        </div>  <?php 
        php;
        ?>
        
        
        <div id="and-or-role-div">
          <?php 
        $checked = 'checked="checked"';
        for ($i = 0; $i < sizeof($vtmin_rule->role_and_or_in); $i++) {
            ?>
                               
              <input id="<?php 
            echo $vtmin_rule->role_and_or_in[$i]['id'];
            ?>
" class="<?php 
            echo $vtmin_rule->role_and_or_in[$i]['class'];
            ?>
" type="<?php 
            echo $vtmin_rule->role_and_or_in[$i]['type'];
            ?>
" name="<?php 
            echo $vtmin_rule->role_and_or_in[$i]['name'];
            ?>
" value="<?php 
            echo $vtmin_rule->role_and_or_in[$i]['value'];
            ?>
" <?php 
            if ($vtmin_rule->role_and_or_in[$i]['user_input'] > ' ') {
                echo $checked;
            } else {
                echo $disabled;
            }
            ?>
    /><span id="<?php 
            echo $vtmin_rule->role_and_or_in[$i]['id'] . '-label';
            ?>
"> <?php 
            echo $vtmin_rule->role_and_or_in[$i]['label'];
            ?>
</span><br /> 
           <?php 
        }
        //if neither 'and' nor 'or' selected, select 'or'
        /*  if ( (!$vtmin_rule->role_and_or_in[0]['user_input'] == 's') && (!$vtmin_rule->role_and_or_in[1]['user_input'] == 's') )   {
                $vtmin_rule->role_and_or_in[1]['user_input'] = 's';
            }   */
        ?>
                 
          </div>
        
        
        <div id="role-in">
          <h3><?php 
        _e('Membership List by Role', 'vtmin');
        ?>
</h3>
          
          <?php 
        // ********************************
        $this->vtmin_post_category_meta_box($post, array('args' => array('taxonomy' => 'roles', 'tax_class' => 'role-in', 'checked_list' => $vtmin_rule->role_in_checked)));
        // ********************************
        ?>
        </div>
        <div class="back-to-top">
            <a title="Back to Top" href="#wpbody"><?php 
        _e('Back to Top', 'vtmin');
        ?>
<span class="back-to-top-arrow">&nbsp;&uarr;</span></a>
        </div>
      </div> <?php 
        //end vtmin-pop-in-cntl
        ?>

   <?php 
    }