php 'salesPrice' to $price [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
My Joomla and virtuemart have a product price salesPrice that is shown by this:
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
Now I need to convert salesPrice to $customprice so I can calculate it in code like this:
<?php
$customprice = ('salesPrice');
$cijenaraw = str_replace(' Kn','',$customprice);
$cijenaraw2 = str_replace('.','',$customprice);
$cijenaraw3 = str_replace(',','.',$cijenaraw2);
$dicscijena = ($cijenaraw3 / 100) * 92;
$novacijena = round($dicscijena, 2);
echo '<p style="margin-top:10px;color: #FF7800;"><strong>*Cijena: '. number_format($custompricefinal, 2, ',', '.') .' HRK</strong></p>';
endif;
?>

The problem is that $customprice = ('salesPrice'); can't give you any value.
If you are using the script in the product details page you have to add:
$customprice = $this->product->prices['salesPrice'];
If it is in the category browse page:
$customprice = $product->prices['salesPrice'];
Now $customprice would have the sales price that you could make calculations.

Related

How can I limit the attached images shown to just one? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Given I'm using the following code:
$images = get_attached_media('image' ); // get attached media
foreach ($images as $image) {
$ximage = wp_get_attachment_image_src($image->ID,'medium');
echo '<img src="' .$ximage[0] . '" />';
}
How can I limit it to just show the first attached image only, rather than all of them?
If you only want to show first image from array, remove the foreach loop and do this:
$images = get_attached_media('image' );
// get first element from array
$image = reset($images );
$ximage = wp_get_attachment_image_src($image->ID,'medium');
echo '<img src="' .$ximage[0] . '" />';

Trying to make this entire line of code into a hyperlink [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
echo <a href = 'test.php'> "CategoryID: " . $row["CategoryID"]. " - Category Name: ".$row["CategoryName"]. </a> "<br>";
This is what i have an is not working properly.
This:
echo "<a href = 'test.php'>CategoryID: {$row['CategoryID']} - Category Name: {$row['CategoryName']}</a><br />";
I am using the { and } as they allow you to include an array in a string and ignore the concatenation which I find harder to read.
I find it funny that you can loop through a MySQL array but can't echo a simple string :P
Some links (teach a man to fish...):
W3Schools
PHP documentation
Codecademy
Tutorials Point
Try this:
<?php
$link = "";
$link = sprintf("<a href = 'test.php'>CategoryID: %d - Category Name: %s </a><br />", $row['CategoryID'], $row['CategoryName']);
echo $link;
?>
Assuming that $row['CategoryID'] is an integer and $row['CategoryName'] is a string.

How will make variable to do_shortcode value? i want to change shortcode value like (category="others") how it possible? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to make variables of these red block parts
(screenshot).
PHP code:
echo do_shortcode('[product_category category="others" per_page="12" columns="4"]');
You can directly insert variable values in a "" delimited string in PHP.
$cat = "some_category";
$per = 20; // some number
$col = 10; // some number
echo do_shortcode("[product_category category=\"$cat\" per_page=\"$per\" columns=\"$col\"]");
If you still want to use a '' delimited string, you need to append values together.
echo do_shortcode('[product_category category="' . $cat . '" per_page="' . $per . '" columns="' . $col . '"]');

How to find the category Id in the wordpress? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am new to wordpress , I need to know how to find the category id instead of category name ?
in the wordpress .
Any one Much appreciated
Reg,
vicky
<?php
$category_id = get_cat_ID('Category Name');
$q = 'cat=' . $category_id;
query_posts($q);
if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;
?>
Taken from the Wordpress Codex: http://codex.wordpress.org/Function_Reference/get_cat_ID
Did you try?
global $wp_query;
$cat_ID = get_query_var('cat');

joomla 2.5 navigation menu subtitle [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Hi I am web designer and I would like to know how to set menu subtitle? It is easily possible with yoo themes but I need to know how it is done without using YooTheme templates. I think there is need of little modification in mod_menu but I don't know what exactly. I googled all day and can't find a solution.
There are certainly better solutions but i've done it this way:
Insert a charakter in the name of your menu-item. For example a "|".
It should look like this: Title | Subtitle. At this position you can divide the name.
Now you have to override the file default_component.php in modules/mod_menu/tmpl.
Add this lines:
$parts = explode("|", $linktype);
// the "|" is the divider
if(isset($parts[1])){
$linktype = $parts[0].'<span>'.$parts[1].'</span>';
}else{
$linktype = $parts[0];
};
after:
$class = $item->anchor_css ? 'class="'.$item->anchor_css.'" ' : '';
$title = $item->anchor_title ? 'title="'.$item->anchor_title.'" ' : '';
if ($item->menu_image) {
$item->params->get('menu_text', 1 ) ?
$linktype = '<img src="'.$item->menu_image.'" alt="'.$item->title.'" /><span class="image-title">'.$item->title.'</span> ' :
$linktype = '<img src="'.$item->menu_image.'" alt="'.$item->title.'" />';
}
else { $linktype = $item->title;
}
Now you have a span around the subtitle and it's possible to style it.

Categories