Osclass forums
Support forums => Themes => Twitter => Topic started by: design on June 18, 2014, 10:17:56 pm
-
I am trying to work on the price fields error that occurs in twitter related themes.
so the error:
when you select on a category and if the price should not be shown it should hide the price field.
I have narrowed it down to a script in the core, but I don't want to change the core-- duh!
so how do I bring that function over into the themes function?
here is the cores syntax(is that the right term?) that I want into the theme
static public function plugin_post_item($case = 'form') {
?>
<script type="text/javascript">
var catPriceEnabled = new Array();
<?php
$categories = Category::newInstance()->listAll(false);
foreach($categories as $c) {
echo 'catPriceEnabled['.$c['pk_i_id'].'] = '.$c['b_price_enabled'].';';
}
?>
$("#catId").change(function(){
var cat_id = $(this).val();
<?php if(OC_ADMIN) { ?>
var url = '<?php echo osc_admin_base_url(true); ?>';
<?php } else { ?>
var url = '<?php echo osc_base_url(true); ?>';
<?php } ?>
var result = '';
if(cat_id != '') {
if(catPriceEnabled[cat_id] == 1) {
$("#price").closest("div").show();
} else {
$("#price").closest("div").hide();
$('#price').val('') ;
}
$.ajax({
type: "POST",
url: url,
data: 'page=ajax&action=runhook&hook=item_<?php echo $case;?>&catId=' cat_id,
dataType: 'html',
success: function(data){
$("#plugin-hook").html(data);
}
});
}
});
$(document).ready(function(){
var cat_id = $("#catId").val();
<?php if(OC_ADMIN) { ?>
var url = '<?php echo osc_admin_base_url(true); ?>';
<?php } else { ?>
var url = '<?php echo osc_base_url(true); ?>';
<?php } ?>
var result = '';
if(cat_id != '') {
if(catPriceEnabled[cat_id] == 1) {
$("#price").closest("div").show();
} else {
$("#price").closest("div").hide();
$('#price').val('') ;
}
$.ajax({
type: "POST",
url: url,
data: 'page=ajax&action=runhook&hook=item_<?php echo $case;?>&catId=' cat_id,
dataType: 'html',
success: function(data){
$("#plugin-hook").html(data);
}
});
}
});
</script>
<div id="plugin-hook">
</div>
-
Hi :)
I couldn't see anything there requiring other ItemForm class functions or properties, so I think it could work just like that, copy the whole function static public function plugin_post_item($case = 'form') in your theme functions.php renaming the function, i.e. cust_plugin_post_item:
function cust_plugin_post_item($case = 'form') {
ant then change in item-post.php:
if($edit) {
ItemForm::plugin_edit_item();
} else {
// ItemForm::plugin_post_item(); // Vanilla
cust_plugin_post_item();
}
Regards
-
so close I can taste it!!
it still shows an inline display none
-
And isn't that the desired effect? ???
Regards
-
no, if the category selected has the price enabled it should show it and it's not.
maybe this? in function
if(cat_id != '') {
if(catPriceEnabled[cat_id] == 1) {
$("#price").closest("div").show();
} else {
$("#price").closest("div").hide();
$('#price').val('') ;
}
I try so many things.... head exploded..try tomorrow
-
Were you able to get this working? if yes - can you please help?
-
yes..let me find the code. BRB, sorry I forgot to update this thread :-( :-X
-
there is a JS one also, but I can't find it. this goes in item.php or depending on your theme
<?php if ( osc_price_enabled_at_items() && osc_item_price() != '' ) { ?>
<strong>
<?php printf( '%s', osc_format_price(osc_item_price()) ); ?>
</strong>
<?php } else { ?>
<strong><?php _e( 'Ask seller for price', ‘your theme ); ?></strong>
<?php } ?>
-
Thank You - design...
Will test this out..