I am working with WooCommerce and have my page where I display a single product and it's single pricing. I am changing everything over to be rated at a variable price (Licensing model).
Here is the Single Product Markup:
<?php
/**
* Template Name: Featured Tracks
*/
get_header(); ?>
<div id="content">
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('page'); ?>>
<h1><?php the_title(); ?></h1>
<?php echo do_shortcode( '[audio file="'.get_post_meta( get_the_ID(), '_track_preview_file', true ).'" desc="'. get_the_title() .'"]' ); ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table table-border table-hover">
<tr>
<th scope="row">Price:</th>
<td><span class="middle"><?php global $product, $woocommerce; $product = get_product( get_the_ID() ); echo $product->get_price_html(); ?></span>
</td>
</tr>
<tr>
<th scope="row">Buy Now:</th>
<td><span class="middle">Add To Cart</span></td>
</tr>
<tr>
<th scope="row">Try It Out:</th>
<td><span class="middle">Download Preview</span></td>
</tr>
<th scope="row">Description:</th>
<td><?php the_excerpt(); ?></td>
</tr>
<tr>
<th scope="row">Catalog:</th>
<td><?php the_terms( get_the_ID(), 'product_catalog', '', ', ', '' ); ?></td>
</tr>
<tr>
<th scope="row">Composer:</th>
<td><?php echo get_post_meta( get_the_ID(), '_track_composer', true ); ?></td>
</tr>
<tr>
<th scope="row">Publisher:</th>
<td><?php echo get_post_meta( get_the_ID(), '_track_publisher', true ); ?></td>
</tr>
<tr>
<th scope="row">Keywords:</th>
<td><?php echo $product->get_tags( ', ', '<span class="tagged_as">', '</span>' ); ?></td>
</tr>
<tr>
<th scope="row">Tempo:</th>
<td><?php echo get_post_meta( get_the_ID(), '_track_temp', true ); ?></td>
</tr>
<tr>
<th scope="row">BPM:</th>
<td><?php echo get_post_meta( get_the_ID(), '_track_bpm', true ); ?></td>
</tr>
<tr>
<th scope="row">Length:</th>
<td><?php echo get_post_meta( get_the_ID(), '_track_length', true ); ?></td>
</tr>
</table>
</div><!-- .catalog-item -->
<?php endwhile; wp_reset_query(); ?>
</div><!--#content-->
<?php get_footer(); ?>
The line that prints out the single price is where I am going to include two different links to add the item to your cart depending on the license you want. I am just not too familiar with WooCommerce enough to make that happen
You don't need to add the two links yourself, that's what WooCommerce Product Variations is designed to do.
Once configured, it will include a dropdown menu and automatically adjust the price for the user based on their selection.
Related
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Agent Name</th>
<th>Total number calls audited</th>
<th>Fatal Count</th>
<th>Score</th>
<th>Average</th>
</tr>
</thead>
<!-- <div style="overflow:scroll;min-height:.01%;overflow-y:hidden;overflow-x:scroll;"> -->
<tbody>
<?php
$totalauditded=0;
$totalfatal=0;
$listau=$aucnt->result();
$totalauditded+=$rpostclist->audited;
$totalfatal+=$rpostclist->cnfatal;
?>
<tr>
<td><?php echo $rpostclist->agent_name;?></td>
<td><?php echo $rpostclist->audited;?></td>
<td><?php echo $rpostclist->cnfatal;?></td>
<td>
<table class="table table-bordered">
<tr>
<?php $i=1; foreach($listau as $raucnt) { ?>
<th> Call <?php echo $i;?><br/><?php echo $raucnt->qa_agent;?><br/><?php echo $raucnt->qa_date; ?><br>View</th>
<?php $i++;} ?>
</tr>
<tr>
<?php $sum = 0; foreach($listau as $raucnt) { ?>
<td><?php echo $raucnt->tot;
$sum += $raucnt->tot;?>%</td>
<?php } ?>
</tr>
</table>
</td>
<td style="vertical-align:middle;font-weight:bold;font-size:20px;"><?php echo round($average=$sum/count($listau));?>%</td>
</tr>
<?php } ?>
<tr>
<td></td>
<td style="font-size:16px;"><strong>Total:<?php echo $totalauditded;?></strong></td>
<td style="font-size:16px;"><strong>Total:<?php echo $totalfatal;?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
I googled but didn't find any solutions. What i'am trying is to keep a horizontal bar at the top of the table since it fetches many data from the database its hard to scroll. Maybe both top and bottom horizontal scroll bar is also good for the suggestions.
I changed my container axis to 180 Degree
<div class=" table-responsive"style="transform: rotateX(180deg);">
<table class="table table-striped" style="transform: rotateX(180deg);">```
Use css
overflow-x : auto;
Reference
https://www.w3schools.com/howto/howto_css_menu_horizontal_scroll.asp
<div class="table-responsive">
change to
<div class="table-responsive" style="overflow-y: scroll; overflow-x: auto">
I'm following a tutorial in Wordpress for Developers. I started to debug the code and I am getting stuck here.
I think it might be a semi-colon? I'm not exactly sure.
The code is as follows:
<div class="wrap">
<h2><?php _e( 'Halloween Store Options', 'halloween-plugin' ) ?></h2>
<form method="post" action="options.php">
<?php settings_fields ( 'halloween-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e( 'Show Product Inventory', 'halloween-plugin' ); ?></th>
<td><input type="checkbox" name="halloween_options[show_inventory]"
<?php echo checked( $hs_inventory, 'on' ); ?> /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Currency Sign', 'halloween-plugin' ) ?></th>
<td><input type="text" name="halloween_options[currency_sign]"
value="<?php echo esc_attr( $hs_currency_sign ); ?>"
size="1" maxlength="1" /></td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary"
value="<?php _e( 'Save Changes', 'halloween-plugin' ); ?>" />
</p>
</form>
</div>
If anyone could help me out, I'd greatly appreciate it.
Try to load the file wp-load.php, before you use the function _e().
require_once('../../../wp-load.php');
I have a page that displays information from a db in a while loop. Using Bootstrap table and a var $loopcounter that gives each line a separate id. When cliking on a line I am able to expand on the information for each row. This works perfect, thanks to SO and Google.
My problem now is that the table is displaying a double line for the hidden/collapsed row. I have tried several solutions like padding:0 !important, border-color: #FFF, border-color: none, nothing seems to work. Also tried colspan, but that only expands the double line further.
HTML:
<table class="table table-striped table-hover">
<thead>
<th>Name</th>
<th>Age</th>
<th>Adr</th>
</thead>
<tbody>
<?php while ($row = $variable->fetch()) { $loopcounter++ ;?>
<tr data-toggle="collapse" data-target="#row<?php echo $loopcounter; ?>" class="accordion-toggle">
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['age']; ?></td>
<td><?php echo $row['adr']; ?></td>
</tr>
<tr>
<td class="hiddenRow"><div class="accordian-body collapse" id="row<?php echo $loopcounter; ?>">
<table>
<thead><tr><td>Some Header</td></tr></thead>
<tbody><tr><td><?php echo $row['name']; ?></td></tr></tbody>
</table>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
CSS:
.hiddenRow {
padding: 0 !important;
border-color: FFF;
}
IMAGE:
Notice the double border when row is collapsed
It had actually a pretty easy solution, just styled the hidden TD with border:none
I want to make a small change on the single-product page about displaying variations.
Normally variations are displayed like this as html.
<table class="variations" cellspacing="0">
<tbody>
<tr>
<td class="label"><label for="group-size">Group Size</label></td>
<td class="value">
<select id="group-size" class="" name="attribute_group-size" data-attribute_name="attribute_group-size">
<option value="">Chose an options</option>
<option value="1 Person" >1 Person</option>
<option value="2 persons" >2 persons</option>
</select>
</td>
</tr>
<tr>
<td class="label"><label for="type-of-activity">Type of Activity</label></td>
<td class="value">
<select id="tipo-de-actividad" class="" name="attribute_tipo-de-actividad" data-attribute_name="attribute_type-of-activity">
<option value="">Chose an option</option>
<option value="Walking" >Walking</option>
<option value="With car" >with car</option>
</select>
<a class="reset_variations" href="#">Clean the selections</a>
</td>
</tr>
</tbody>
</table>
But I want to have like this
<table class="variations" cellspacing="0">
<tbody>
<tr>
<td class="label"><label for="group-size">Group Size</label></td>
</tr>
<tr>
<td class="value">
<select id="group-size" class="" name="attribute_group-size" data-attribute_name="attribute_group-size">
<option value="">Chose an options</option>
<option value="1 Person" >1 Person</option>
<option value="2 persons" >2 persons</option>
</select>
</td>
</tr>
<tr>
<td class="label"><label for="type-of-activity">Type of Activity</label></td>
</tr>
<tr>
<td class="value">
<select id="tipo-de-actividad" class="" name="attribute_tipo-de-actividad" data-attribute_name="attribute_type-of-activity">
<option value="">Chose an option</option>
<option value="Walking" >Walking</option>
<option value="With car" >with car</option>
</select>
<a class="reset_variations" href="#">Clean the selections</a>
</td>
</tr>
</tbody>
</table>
Means that i wantto have the labels inside a row just above the options.
How we can do that?
I got the solution myself.
There is variable.php in
wp-content/plugins/woocommerce/templates/single-product/add-to-cart
I opened that file
ı have changed
<table class="variations" cellspacing="0">
<tbody>
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
<tr>
<td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
<td class="value">
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
to
<table class="variations" cellspacing="0">
<tbody>
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
<tr>
<td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
</tr>
<tr>
<td class="value">
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
Result was as i like.
Sorry for disturbing you.
OK so i have a plugin which has its own settings page and all. In the settings i have a form that will display data from a custom table. It looks like this:
<form method="post" action="">
<table>
<tbody>
<tr>
<th>StringVal1</th>
<th>Checked</th>
<th>StringVal2</th>
<th>StringVal3</th>
<th>Configurations</th>
</tr>
<tr>
<td>
<?php echo "Value from table"; ?>
</td>
<td>
<?php
if ($row["Checked"] == 1) {
$checked = ' checked="checked" ';
}
echo "<input name='Checked' type='checkbox' " . $checked . " />";
?>
</td>
<td>
<?php echo "Another value from table"; ?>
</td>
<td>
<?php echo "More value from table"; ?>
</td>
<th>
<div align="center">
<input name="EditButton" type="submit" class="edit-secondary" value="Edit">
</div>
</th>
</tr>
</tbody>
</table>
</form>
When the "Edit" Button is clicked i want to link to another page (for ex. /wp-admin/plugins.php?page=myplugin-settings/edit-form) in order to edit and insert delete rows from the table. So how can i add that extra page i need?