Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: duplicate_product.php
<?php define('APP_CURRENCY', $this->db->get_where('tbl_gf_ecomm_settings', array('id' => '1'))->row()->app_currency_code); define('CURRENCY_CODE', $this->db->get_where('tbl_gf_ecomm_settings', array('id' => '1'))->row()->app_currency_html_code); define('THEME', $this->db->query("SELECT * FROM `tbl_gf_email_settings` WHERE Id = 1")->row()->Theme); ?> <!-- Page header --> <div class="page-header border-bottom-0"> <div class="page-header-content header-elements-md-inline"> <div class="page-title d-flex"> <h4><a href="javascript:void(0)" class="BackButton-Link" onclick="goBack()"><i class="icon-arrow-left52 mr-2"></i></a> <?=$current_page?></h4> </div> </div> </div> <!-- /page header --> <!-- Content area --> <div class="content pt-0"> <div class="card"> <div class="row"> <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12"> <div class="card-body"> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="clearfix"></div> <div class="card-body mrg_bottom"> <?php if($this->session->flashdata('response_msg')) { $message = $this->session->flashdata('response_msg'); ?> <div class="<?=$message['class']?>" role="alert"> <?=$message['message']?> </div> <?php } ?> <?php define('IMG_PATH', base_url('uplds'.THEME.'/ecomm/images/products').'/'); define('IMG_PATH_GALLERY', base_url('uplds'.THEME.'/ecomm/images/products/gallery').'/'); if($this->session->flashdata('response_msg')) { $message = $this->session->flashdata('response_msg'); ?> <div class="<?=$message['class']?>" role="alert"> <?=$message['message']?> </div> <?php } ?> <form action="<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/add').get_query_string(); ?>" method="post" id="categoryForm" class="form form-horizontal" enctype="multipart/form-data"> <div class="section"> <div class="section-body"> <div class="form-group row"> <label class="col-md-3 control-label">Category :-</label> <div class="col-md-6"> <select name="category_id" class="select2" required=""> <option value="0" selected>--Select Category--</option> <?php foreach ($category_list as $key => $value) { ?> <option class="level_0" <?php echo $value['id'] == $product[0]->category_id ? 'selected=""' : ''; ?> value="<?=$value['id']?>"><?= $value['category_name']; ?></option> <?php echo get_sub_cats_options($value); ?> <?php } ?> </select> </div> </div> <?php echo '<input type="hidden" class="old_brand_id" value="'.$product[0]->brand_id.'">'; ?> <div class="form-group row"> <label class="col-md-3 control-label">Brand :-</label> <div class="col-md-6"> <select name="brand_id" class="select2" id="brand_id"> <option value="0" selected>--Select Brand--</option> </select> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label">Product Title :- </label> <div class="col-md-6"> <input type="text" name="title" id="product_title" value="<?= $product[0]->product_title; ?>" class="form-control" placeholder="Enter product title" required> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label">Product Short Description :-</label> <div class="col-md-6"> <textarea name="product_desc" id="product_desc" class="form-control" rows="5"><?= $product[0]->product_desc; ?></textarea> </div> </div> <br/> <div class="form-group row"> <label class="col-md-3 control-label">Product Features :-</label> <div class="col-md-6"> <textarea name="product_features_desc" id="product_features_desc" required="" class="form-control"><?= $product[0]->product_features; ?></textarea> </div> </div> <br/> <div class="form-group row"> <label class="col-md-3 control-label sku"><abbr title="Maximum Retail Price">SKU</abbr> :-</label> <div class="col-md-6"> <input type="text" name="product_sku" id="product_sku" value="<?= $product[0]->product_sku; ?>" class="form-control" placeholder="" onkeypress="" required> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label mrp"><abbr title="Maximum Retail Price">M.R.P</abbr> :-</label> <div class="col-md-6"> <input type="text" name="product_mrp" id="product_mrp" value="<?= $product[0]->product_mrp; ?>" class="form-control" placeholder="" onkeypress="return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13) ? null : event.charCode >= 48 && event.charCode <= 57" required> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label quantity">Quantity In Stock :-</label> <div class="col-md-6"> <input type="text" name="quantity" id="quantity" value="<?= $product[0]->quantity; ?>" class="form-control" placeholder="" required> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label re_order">Reorder / Low Stock Quantity :-</label> <div class="col-md-6"> <input type="text" name="low_quantity" id="low_quantity" value="<?= $product[0]->low_quantity; ?>" class="form-control" placeholder="" required> </div> </div> <div class="form-group row"> <?php echo '<input type="hidden" class="old_offer_id" value="'.$product[0]->offer_id.'">'; ?> <label class="col-md-3 control-label">Apply Offer :-</label> <div class="col-md-6"> <select name="offer_id" id="offer_id" class="select2"> <option value="0" selected>--Select Offer--</option> <?php foreach ($offer_list as $key => $value) { ?> <option value="<?=$value->id?>" <?= $product[0]->offer_id==$value->id ? 'selected=""' : ''; ?>><?=$value->offer_title?></option> <?php } ?> </select> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label">Selling Price :-</label> <div class="col-md-6"> <input type="text" name="selling_price" id="selling_price" readonly="" value="<?= $product[0]->selling_price; ?>" class="form-control" placeholder=""> </div> </div> <div class="form-group row saving_info" style="display: none;"> <label class="col-md-9 col-md-offset-3 control-label" style="padding-top: 0px"> <strong style="color: green">1 offer is applied !</strong> </label> <label class="col-md-3 control-label">You Save :- </label> <div class="col-md-3"> <div class="input-group"> <input type="text" name="you_save" id="you_save_price" readonly="readonly" value="" class="form-control" placeholder="Saving in <?=APP_CURRENCY?>"> <span class="input-group-addon"><?=CURRENCY_CODE?></span> </div> </div> <div class="col-md-3"> <div class="input-group"> <input type="text" name="you_save_per" id="you_save_per" readonly="readonly" value="" class="form-control" placeholder="Saving in Percentage"> <span class="input-group-addon"><i class="fa fa-percent"></i></span> </div> </div> </div> <input type="hidden" name="product_quantity" value="0"> <?php if($settings->maxbuy_field){?> <div class="form-group row"> <label class="col-md-3 control-label">Max Unit Buy :- </label> <div class="col-md-6"> <input type="text" name="max_unit_buy" id="max_unit_buy" value="<?= $product[0]->max_unit_buy; ?>" class="form-control" required placeholder="1"> </div> </div> <?php }?> <div class="form-group row"> <label class="col-md-3 control-label">Featured Image-1 :- <p class="control-label-help hint_lbl">(Recommended resolution: 600x600,600x600 or Square Image And Large Image)</p> <p class="control-label-help hint_lbl">(Accept only png, jpg, jpeg, gif image files)</p> </label> <div class="col-md-6"> <div class="fileupload_block"> <input type="file" required="" name="file_name" value="fileupload" id="fileupload" accept="image/*"> <div class="fileupload_img mt-2"><img type="image" src="<?php echo base_url('uplds'.THEME.'/ecomm/images/no-image-1.jpg'); ?>" alt="product image" style="width: auto;height: 90px" /></div> </div> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label">Featured Image-2 :- <p class="control-label-help hint_lbl">(Recommended resolution: 600x600,800x800 or Square Image And Large Image)</p> <p class="control-label-help hint_lbl">(Accept only png, jpg, jpeg, gif image files)</p> </label> <div class="col-md-6"> <div class="fileupload_block"> <input type="file" required="" name="file_name2" value="fileupload" id="fileupload" accept="image/*"> <div class="fileupload_img mt-2"><img type="image" src="<?php echo base_url('uplds'.THEME.'/ecomm/images/no-image-1.jpg'); ?>" alt="product image" style="width: auto;height: 90px" /></div> </div> </div> </div> <div class="form-group row"> <label class="col-md-3 control-label">Product Image Gallery :- <p class="control-label-help hint_lbl">(Recommended resolution: 600x600,800x800 or Square Image And Large Image)</p> <p class="control-label-help hint_lbl">(Accept only png, jpg, jpeg, gif image files)</p> </label> <div class="col-md-6"> <input type="file" name="product_images[]" value="" id="fileupload" accept="image/*" class="form-control" multiple=""> </div> </div> <hr/> <?php $color_name=$color_code=''; echo '<input type="hidden" class="old_color_id" value="'.$product[0]->other_color_product.'">'; ?> <div class="product_features"> <div class="form-group row" style="display: none;"> <label class="col-md-3 control-label">Size Chart:- <p class="control-label-help hint_lbl">(Accept only png, jpg, jpeg, gif image files)</p> </label> <div class="col-md-6"> <div class="fileupload_block"> <input type="file" name="size_chart" value="fileupload" id="fileupload" accept="image/*"> <div class="fileupload_img mt-2"><img type="image" src="<?php echo base_url('uplds'.THEME.'/ecomm/images/no-image-1.jpg'); ?>" alt="product image" style="width: auto;height: 90px" /></div> </div> </div> </div> </div> <?php if($settings->delivery_field){?> <div class="form-group row"> <label class="col-md-3 control-label">Delivery Charge :- </label> <div class="col-md-6"> <input type="text" name="delivery_charge" id="delivery_charge" value="<?= $product[0]->delivery_charge; ?>" class="form-control" placeholder="Enter product delivery charge" required> </div> </div> </div> <?php }?> <div class="form-group row"> <div class="col-md-9 col-md-offset-3"> <label>Mark As New Arrivals :-</label> <input type="checkbox" id="new_arrival" name="new_arrival" data-id="" <?= $product[0]->new_arrival==1 ? 'checked' : ''; ?> class="cbx hidden enable_disable_newArrival"> <label for="new_arrival" class="lbl" ></label> </div> </div> <br/> <div class="form-group row"> <div class="col-md-9 col-md-offset-3"> <label>Mark As Featured :-</label> <input type="checkbox" id="is_featured" name="is_featured" data-id="" <?= $product[0]->is_featured==1 ? 'checked': ''; ?> class="cbx hidden enable_disable_is_featured"> <label for="is_featured" class="lbl" ></label> </div> </div> <br/> <div class="form-group row"> <div class="col-md-9 col-md-offset-3"> <input type="hidden" name="is_duplicate" value="1"> <input type="hidden" name="product_slug" value="<?php echo $product[0]->product_slug; ?>"> <button type="submit" name="btn_submit" class="btn btn-primary">Save</button> </div> </div> </div> </form> </div> </div> </div> </div> </div> </div> </div> </div> </div> <script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script> <script type="text/javascript"> $(function(){ $('.default_variation_wrapper').click(function(){ $('.default_variation_wrapper input[type="radio"]:checked').prop('checked', false); $(this).find('input[type="radio"]').prop('checked', true); }); $(document).on('show','.accordion', function (e) { $(e.target).prev('.accordion-heading').addClass('accordion-opened'); }); $(document).on('hide','.accordion', function (e) { $(this).find('.accordion-heading').not($(e.target)).removeClass('accordion-opened'); }); $(".imgInp").change(function() { var id = $(this).data('id'); if ($(this)[0].files.length) { var reader = new FileReader(); reader.onload = function(e) { $('.blah'+id).attr('src', e.target.result); } reader.readAsDataURL($(this)[0].files[0]); // convert to base64 string } }); }); function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $("input[name='file_name']").next(".fileupload_img").find("img").attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } function formatResult(node) { var level = 0; if(node.element !== undefined){ level = (node.element.className); if(level.trim() !== ''){ level = (parseInt(level.match(/\d+/)[0])); } } var $result = $('<span style="padding-left:' + (20 * level) + 'px;">' + node.text + '</span>'); return $result; }; $("input[name='file_name']").change(function() { readURL(this); }); function readURL2(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $("input[name='file_name2']").next(".fileupload_img").find("img").attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } $("input[name='file_name2']").change(function() { readURL2(this); }); function readURL3(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $("input[name='size_chart']").next(".fileupload_img").find("img").attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } $("input[name='size_chart']").change(function() { readURL3(this); }); </script> <script type="text/javascript"> CKEDITOR.replace( 'product_features_desc', { removePlugins: 'link,about', removeButtons:'Subscript,Superscript,Image', } ); </script> <script type="text/javascript"> // edit product var product_id=$(".product_id").val(); var _id=$("select[name='category_id']").val(); // for sub category var _old_id_sub=$(".old_sub_cat_id").val(); $("select[name='sub_cat_id']").html('<option value="0">--Select Sub-Category--</option>'); var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/get_sub_category'); ?>/'+_id; $.ajax({ type:'GET', url:href, success:function(res){ $("select[name='sub_cat_id']").append(res); $('#sub_category_id option[value="'+_old_id_sub+'"]').prop('selected', true); } }); // for brands var _old_id_brand=$(".old_brand_id").val(); $("select[name='brand_id']").html('<option value="0">--Select Brand--</option>'); var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/get_brands'); ?>/'+_id; $.ajax({ type:'GET', url:href, success:function(res){ $("select[name='brand_id']").append(res); $('#brand_id option[value="'+_old_id_brand+'"]').prop('selected', true); } }); var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/get_featured'); ?>/'+_id; $.ajax({ type:'GET', url:href, success:function(res){ res=$.trim(res); var res_arr = res.split(","); $.each(res_arr, function( index, value ) { $(".product_features").find("."+value).show(); }); } }); var _old_id_ofr=$(".old_offer_id").val(); var _mrp=parseFloat($("input[name='product_mrp']").val()); if(_old_id_ofr!=0){ var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/calculate_offer'); ?>/'+_old_id_ofr+'/'+_mrp; $.ajax({ type:'GET', url:href, success:function(res){ $('#offer_id option[value="'+_old_id_ofr+'"]').prop('selected', true); $obj=$.parseJSON(res); $("input[name='selling_price']").val($obj.selling_price); if(_old_id_ofr!=0){ $("input[name='selling_price']").css("borderColor","green"); $(".saving_info").show(); } else{ $("input[name='selling_price']").css("borderColor","#999"); $(".saving_info").hide(); } $("input[name='you_save']").val($obj.you_save); $("input[name='you_save_per']").val($obj.you_save_per); } }); } else{ $("input[name='selling_price']").val(_mrp); } var old_color_id=$(".old_color_id").val(); var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/get_color_products'); ?>'; $.ajax({ type:'POST', url:href, data: {brand_id: _old_id_brand, cat_id:_id, curr_id:product_id}, success:function(res){ $obj=$.parseJSON(res); if($obj.status){ $(".other_color_product").show(); $("#other_color_product").append($obj.data); if(old_color_id!=''){ var res_arr = old_color_id.split(","); $.each(res_arr, function( index, value ) { $('#other_color_product option[value="'+value+'"]').prop('selected', true); }); } } } }); $(document).ready(function(e){ $("input[name='product_mrp']").keyup(function(e){ if($(this).val()!=''){ var _mrp=parseInt($(this).val()); $("input[name='selling_price']").val($(this).val()); } }); $('.select2').not("[name='category_id']").select2(); $("[name='category_id']").select2({ placeholder: 'Select an option', width: "300px", templateResult: formatResult, }); // apply offser $("select[name='offer_id']").on("change",function(e){ var _mrp=parseInt($("input[name='product_mrp']").val()); var _id=$(this).val(); var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/calculate_offer'); ?>/'+_id+'/'+_mrp; $.ajax({ type:'GET', url:href, success:function(res){ $obj=$.parseJSON(res); $("input[name='selling_price']").val($obj.selling_price); if(_id!=0){ $("input[name='selling_price']").css("borderColor","green"); $(".saving_info").show(); } else{ $("input[name='selling_price']").css("borderColor","#999"); $(".saving_info").hide(); } $("input[name='you_save']").val($obj.you_save); $("input[name='you_save_per']").val($obj.you_save_per); } }); }); $(".remove_img").click(function(e){ e.preventDefault(); var _id=$(this).data("id"); var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/remove'); ?>/'+_id; var btn = this; swal({ title: "Are you sure ?", type: "warning", showCancelButton: true, confirmButtonClass: "btn-danger btn_edit", cancelButtonClass: "btn-warning btn_edit", confirmButtonText: "Yes", cancelButtonText: "No", closeOnConfirm: false, closeOnCancel: false, showLoaderOnConfirm: true }, function(isConfirm) { if (isConfirm) { $.ajax({ type:'GET', url:href, success:function(res){ if($.trim(res)=='success'){ swal.close(); $(btn).closest('div').fadeOut("200"); } else { alert("Error"); } } }); } else{ swal.close(); } }); }); // other product colors $("select[name='brand_id']").change(function(e){ var brand_id=$(this).val(); var cat_id=$("select[name='category_id']").val(); var curr_id=0; if(product_id!=''){ curr_id=product_id; } var href = '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/get_color_products'); ?>'; if(cat_id!=''){ $.ajax({ type:'POST', url:href, data: {brand_id: brand_id, cat_id:cat_id, curr_id:curr_id}, success:function(res){ $obj=$.parseJSON(res); if($obj.status){ $(".other_color_product").show(); $("#other_color_product").append($obj.data); } } }); } }); }); $(".enable_disable_newArrival").on("click",function(e){ var href; var btn = this; var _id = curr_id; var _for=$(this).prop("checked"); if(_for==false){ href='<?= base_url($this->config->item('apanel_name').'/ecomm/products/newarrivalDeactive'); ?>/'+_id; }else{ href='<?= base_url($this->config->item('apanel_name').'/ecomm/products/newarrivalActive'); ?>/'+_id; } $.ajax({ type:'GET', url:href, success:function(res){ $('.notifyjs-corner').empty(); $.notify( res, { position:"top center",className: 'success' } ); } }); }); $(".enable_disable_is_featured").on("click",function(e){ var href; var btn = this; var _id= curr_id; var _for=$(this).prop("checked"); if(_for==false){ href='<?= base_url($this->config->item('apanel_name').'/ecomm/products/is_featured_deactive'); ?>/'+_id; }else{ href='<?= base_url($this->config->item('apanel_name').'/ecomm/products/is_featured_active'); ?>/'+_id; } $.ajax({ type:'GET', url:href, success:function(res){ $('.notifyjs-corner').empty(); $.notify( res, { position:"top center",className: 'success' } ); } }); }); $('.add_variations').click(function(){ if ($(this).is(':checked')) { $('.mrp').html('Variations Default M.R.P :-'); $('.quantity').html('Default Variation Quantity In Stock :-'); $('.re_order').html('Default Variations Reorder / Low Stock Quantity :-'); }else{ $('.mrp').html('M.R.P :-'); $('.quantity').html('Quantity In Stock :-'); $('.re_order').html('Reorder / Low Stock Quantity :-'); } }); $('.ignore_variation').on('change', function() { if($(this).prop('checked')) { if(confirm("Please Note That, If your ignore variation, It will be hidden in the system. If the product out of stock, " + "Please update the stock quantity to zero. " + "\n" + "Are Your Sure You Want To Ignore The Variation? ")) { $(this).prop('checked', true); } else { $(this).prop('checked', false); } } }); $('#product_sku').on('change',function(){ var sku= $('#product_sku').val(); $.ajax({ type: 'post', url : '<?php echo base_url($this->config->item('apanel_name').'/ecomm/products/check_sku'); ?>', data : {'sku' : sku }, success : function(res){ var obj = $.parseJSON(res); if(obj.status == false){ swal({ title: "SKU must be unique", type: "warning", confirmButtonText: "OK", },function () { $('#product_sku').val(''); } ); } } }) }); </script>