I have a problem with
woocommerce_quantity. Everything works fine now, but woocommerce_quantity appears twice in the frontend. I have already searched various sites and have not yet found a solution to the problem.
Here is my code:
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$current_lang = pll_current_language();
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false ); <-- Here is the quantity i needed.
$html .= '<input type="hidden" name="lightbox_for_products" value="1">';
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
$html .= '<div id="ts_shop_modal_products" class="modal">';
$html .= '<div class="modal-content">';
$html .= '<span class="close">×</span>';
if ( $current_lang == 'de' ) {
$html .= '<button class="button alt"><a style="color: #fff" href="' . wc_get_cart_url() . '">'. pll__( 'Zum Warenkorb' ) .'</a></button><br/><br/>';
$html .= '<button class="button alt"><a style="color: #fff" href="'. get_bloginfo('url') .'/eintrittskartenshop/" >' . pll__( 'Zurück zur Übersicht' ) . '</a></button>';
} else {
$html .= '<button class="button alt"><a style="color: #fff" href="' . wc_get_cart_url() . '">'. pll__( 'Zum Warenkorb' ) .'</a></button><br/><br/>';
$html .= '<button class="button alt"><a style="color: #fff" href="'. get_bloginfo('url') .'/en/shop" >' . pll__( 'Zurück zur Übersicht' ) . '</a></button>';
}
$html .= '</div>';
$html .= '</div>';
}
In frontend it looks like this:
Related
Hello i have a table when i want to display some td value = 0 if the status of the task has the id=52!
Down i will put a picture of the table!
I tried to use this code for that:
if ($status['id']) { $calC = $calCminusrealcost = $realCost =0; }
Here $calC, $calCminusrealcost and $realCost are the values i want to become 0!
Here is the pucture of the table: [!https://i.stack.imgur.com/YWOwb.png][1]][1]
So after i use this code it works but in general for all tasks, not just for those which have the id = 52, and if i try to replace id with 52 in the function it doesn't work!
Does someone know what can I do?
this is the full code i have about status:
$outputStatus = '';
$outputStatus .= '<span class="inline-block label" style="color:' . $status['color'] . ';border:1px solid ' . $status['color'] . '" task-status-table="' . $aRow['status'] . '">';
$outputStatus .= $status['name'];
if ($canChangeStatus) {
$outputStatus .= '<div class="dropdown inline-block mleft5 table-export-exclude">';
$outputStatus .= '<a href="#" style="font-size:14px;vertical-align:middle;" class="dropdown-toggle text-dark" id="tableTaskStatus-' . $aRow['id'] . '" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">';
$outputStatus .= '<span data-toggle="tooltip" title="' . _l('ticket_single_change_status') . '"><i class="fa fa-caret-down" aria-hidden="true"></i></span>';
$outputStatus .= '</a>';
$outputStatus .= '<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="tableTaskStatus-' . $aRow['id'] . '">';
foreach ($task_statuses as $taskChangeStatus) {
if ($aRow['status'] != $taskChangeStatus['id']) {
$outputStatus .= '<li>
<a href="#" onclick="task_mark_as(' . $taskChangeStatus['id'] . ',' . $aRow['id'] . '); return false;">
' . _l('task_mark_as', $taskChangeStatus['name']) . '
</a>
</li>';
}
}
if ($status['id']) {
$calC = $calCminusrealcost = $realCost =0;
}
$outputStatus .= '</ul>';
$outputStatus .= '</div>';
}
$outputStatus .= '</span>';
$row[] = $outputStatus;
[1]: https://i.stack.imgur.com/YWOwb.png
This code added currency switcher to a menu,
But unfortunately I don't have access to MySQL database so I can't add image "flag" to each currency, then execute them
So I tried to use if statement.
This is my code:
$currency_switcher_enable = houzez_option('currency_switcher_enable');
$is_multi_currency = houzez_option('multi_currency');
if( $currency_switcher_enable != 0 && $is_multi_currency != 1 ) {
if (class_exists('FCC_Rates')) {
$supported_currencies = houzez_get_list_of_supported_currencies();
if (0 < count($supported_currencies)) {
$current_currency = houzez_get_wpc_current_currency();
echo '<li class="btn-price-lang btn-price">';
echo '<form id="houzez-currency-switcher-form" method="post" action="#" class="open">';
echo '<button id="houzez-selected-currency" class="btn dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><span>' . $current_currency . '</span> <i class="fa fa-sort"></i></button>';
echo '<ul id="houzez-currency-switcher-list" class="dropdown-menu" aria-labelledby="dropdown" style="display:none;">';
foreach ($supported_currencies as $currency_code) {
echo '<li data-currency-code="' . $currency_code . '">' . $currency_code . '</li>';
if (data-currency-code='EUR') {
echo '<img src="images/euro-flag.png"';
if (data-currency-code='TR') {
echo '<img src="images/turkish-flag.png"';
}
}
echo '</ul>';
echo '<input type="hidden" id="houzez-switch-to-currency" name="houzez_switch_to_currency" value="' . $current_currency . '" />';
echo '<input type="hidden" id="currency_switch_security" name="nonce" value="' . wp_create_nonce('houzez_currency_converter_nonce') . '"/>';
echo '</form>';
echo '</li>';
}
}
}
?>
But it doesn't work? What I'm doing wrong?
This is the original code:
$currency_switcher_enable = houzez_option('currency_switcher_enable');
$is_multi_currency = houzez_option('multi_currency');
if( $currency_switcher_enable != 0 && $is_multi_currency != 1 ) {
if (class_exists('FCC_Rates')) {
$supported_currencies = houzez_get_list_of_supported_currencies();
if (0 < count($supported_currencies)) {
$current_currency = houzez_get_wpc_current_currency();
echo '<li class="btn-price-lang btn-price">';
echo '<form id="houzez-currency-switcher-form" method="post" action="#" class="open">';
echo '<button id="houzez-selected-currency" class="btn dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><span>' . $current_currency . '</span> <i class="fa fa-sort"></i></button>';
echo '<ul id="houzez-currency-switcher-list" class="dropdown-menu" aria-labelledby="dropdown" style="display:none;">';
foreach ($supported_currencies as $currency_code) {
echo '<li data-currency-code="' . $currency_code . '">' . $currency_code . '</li>';
}
echo '</ul>';
echo '<input type="hidden" id="houzez-switch-to-currency" name="houzez_switch_to_currency" value="' . $current_currency . '" />';
echo '<input type="hidden" id="currency_switch_security" name="nonce" value="' . wp_create_nonce('houzez_currency_converter_nonce') . '"/>';
echo '</form>';
echo '</li>';
}
}
}
?>
You have many fails here:
The first is as #kerbh0lz mentioned, the "=" and "==" is not the same purpose. here yours is wrong.
Second your second currency If is in the 1st Currency If so it wont ever pass by.
Third you are comparing a string without quote or a var without $ before data-currency-code so instead you should use $currency_code
Try this:
foreach ($supported_currencies as $currency_code) {
echo '<li data-currency-code="' . $currency_code . '">' . $currency_code . '</li>';
if ($currency_code =='EUR')
echo '<img src="images/euro-flag.png"';
elseif ($currency_code == 'TR')
echo '<img src="images/turkish-flag.png"';
}
I am trying to use an IF statement if variable $credit is not empty. However, I get a parse error. Could anyone please help with my syntax?
$credit = get_field('fl_credit', $image['id']);
return '<div class="kalim"><img title="' .
esc_attr( sprintf( the_title_attribute( 'echo=0' ) ) ) .
'" alt="' . esc_attr( sprintf( the_title_attribute( 'echo=0' ) ) ) .
'" src="' . $image['url'] . '" /><div class="kalca">' .
$image['caption'] . '</div>' .
if($credit) {'<div class="kalcr">Credit:' . $credit . '</div></div>' };
Without knowing the error, I suggest do a short if, so:
$credit = get_field('fl_credit', $image['id']);
return '<div class="kalim"><img title="' .
esc_attr( sprintf( the_title_attribute( 'echo=0' ) ) ) .
'" alt="' . esc_attr( sprintf( the_title_attribute( 'echo=0' ) ) ) .
'" src="' . $image['url'] . '" /><div class="kalca">' .
$image['caption'] . '</div>' .
(!empty($credit) ? '<div class="kalcr">Credit:' . $credit . '</div></div>': '' ) ;
You can see more here
Check this if it help you
<?php
$credit = get_field('fl_credit', $image['id']);
$return_data = '<div class="kalim"><img title="'.esc_attr( sprintf( the_title_attribute( 'echo=0' ) ) ) . '" alt="' . esc_attr( sprintf( the_title_attribute( 'echo=0' ) ) ) . '" src="' . $image['url'] . '" /><div class="kalca">' . $image['caption'] . '</div>';
if(!empty($credit)){
$return_data .= '<div class="kalcr">Credit:' . $credit . '</div>';
}
$return_data .= '</div>';
return $return_data;
?>
Being a complete numpty at this....
I am having troubles getting the below code to work (just shows the white screen of death)
case 'venue' :
if( self::isValid($atts['venue'])) {
$output .= '<td>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span></td>';
if( !empty(tribe_get_event_website_link()) ) {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_website_link() . '">Bookings</a></td>';
} else {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_link() . '">Read More</a></td>';
}
}
}
break;
The original code was
case 'venue' :
if( self::isValid($atts['venue'])) {
$output .= '<td>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span></td>';
}
break;
This works fine..
Any assistance appreciated and respected!!
You can try this :
if( self::isValid($atts['venue'])) {
$output .= '<td>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span></td>';
$is_value = tribe_get_event_website_link();
if( !empty($is_value) ) {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_website_link() . '">Bookings</a></td>';
} else {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_link() . '">Read More</a></td>';
}
}
You can't use function return value like this.
I want to implement this <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> into the following function.
function list_my_categories($exclude = '') {
if (!empty($exclude)) {
$exclude = 'exclude=' . $exclude;
}
$categories = get_categories($exclude);
$html = '';
foreach ($categories as $cat) {
if($cat->category_parent == 0) {
<img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
$html .= '<p>' . $cat->cat_name . '</p>';
$html .= '<p>' . $cat->category_description . '</p>';
$childcategories = get_categories('child_of='.$cat->cat_ID.'');
if(!empty($childcategories)){
foreach ($childcategories as $ccat) {
$html .= '<p>' . $ccat->cat_name . '</p>';
$html .= '<p>' . $ccat->category_description . '</p>';
}
}
}
}
return $html;
}
add_shortcode('show-cats', 'list_my_categories');
The function shows a list of categories in WordPress, and I have another plugin which allows you to set an image for each category, so i am trying to show it...
if($cat->category_parent == 0)
{
$html .= '<img src="' . z_taxonomy_image_url($cat->term_id) . '" />';
$html .= '<p>' . $cat->cat_name . '</p>';
$html .= '<p>' . $cat->category_description . '</p>';
$childcategories = get_categories('child_of='.$cat->cat_ID.'');
if(!empty($childcategories))
{
foreach ($childcategories as $ccat)
{
/*$html .= '<img src="' . z_taxonomy_image_url($ccat->term_id) . '" />';*/
$html .= '<p>' . $ccat->cat_name . '</p>';
$html .= '<p>' . $ccat->category_description . '</p>';
}
}
}