Simba123
Forum Replies Created
-
Forum: Plugins
In reply to: [WC Variations Radio Buttons] Selected option not highlightedTry adding this css to see if it works:
input[type=”radio”]:checked + label {
color: black;
}Forum: Hacks
In reply to: SQL sum of custom field split into monthsMarking as resolved.
Forum: Hacks
In reply to: SQL sum of custom field split into monthsIf anyone needs to add multiple sums with different queries from the same table this is how you do it.
My example:
– I needed to show the sum of total_invoice_cost if paid had been set to ‘yes, no or overdue’.– Each sum case has a different alias ie. yes, overdue, no, grandtotal
– These aliases are then used to individually show each sum (right at the bottom)
Here is the code:
<?php global $wpdb; $results = $wpdb->get_results( "SELECT SUM(total_invoice_cost) AS expecting, SUM(case WHEN paid='yes' THEN total_invoice_cost ELSE 0 END) AS yes, SUM(case WHEN paid='overdue' THEN total_invoice_cost ELSE 0 END) AS overdue, SUM(case WHEN paid='no' THEN total_invoice_cost ELSE 0 END) AS no, CONCAT( YEAR(post_date), '-', MONTH(post_date) ) AS grandtotal FROM ( SELECT ID, total_invoice_cost.meta_value AS total_invoice_cost, paid.meta_value AS paid, wp_posts.post_date FROM wp_posts LEFT OUTER JOIN (SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key='paid') paid ON wp_posts.id=paid.post_id LEFT OUTER JOIN (SELECT post_id, meta_value, meta_key FROM wp_postmeta WHERE meta_key='total_invoice_cost') total_invoice_cost ON wp_posts.id=total_invoice_cost.post_id ) x WHERE total_invoice_cost IS NOT NULL GROUP BY CONCAT( YEAR(post_date), '-', MONTH(post_date) ) "); if(!empty($results)) { foreach($results as $r) { echo "<p>".$r->grandtotal."</p>"; echo "<p>EXPECTING IN THIS MONTH £".$r->expecting."</p>"; echo "<p>PAID IN £".$r->yes."</p>"; echo "<p>NOT PAID £".$r->no."</p>"; echo "<p>OVERDUE £".$r->overdue."</p>"; } } else { echo "<p>No invoices!</p>"; } ?>
And here is an example output:
2014-3 EXPECTING IN THIS MONTH £50 PAID IN £50 NOT PAID £0 OVERDUE £0 2015-3 EXPECTING IN THIS MONTH £170 PAID IN £100 NOT PAID £70 OVERDUE £0
Forum: Hacks
In reply to: SQL sum of custom field split into monthsThis is my final working code:
<?php global $wpdb; $sum = '0'; $results = $wpdb->get_results("SELECT SUM(x.total_invoice_cost) AS final ,CONCAT( YEAR(x.post_date), '-', MONTH(x.post_date) ) AS grandtotal FROM ( SELECT ID, total_invoice_cost.meta_value AS total_invoice_cost, paid.meta_value AS paid, wp_posts.post_date FROM wp_posts LEFT OUTER JOIN (SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key='paid') paid ON wp_posts.id=paid.post_id LEFT OUTER JOIN (SELECT post_id, meta_value, meta_key FROM wp_postmeta WHERE meta_key='total_invoice_cost') total_invoice_cost ON wp_posts.id=total_invoice_cost.post_id ) x WHERE x.total_invoice_cost IS NOT NULL AND x.paid='yes' GROUP BY CONCAT( YEAR(x.post_date), '-', MONTH(x.post_date) )"); if(!empty($results)) { foreach($results as $r) { echo "<p>".$r->grandtotal."</p>"; echo "<p>£".$r->final."</p>"; } } else { echo "<p>No invoices this month!</p>"; } ?>
It outputs like this:
2015-4 £100 2015-3 £50
I’m not sure if this is secure and/or open to SQL injections etc. I would appreciate it if someone could check it over and make sure it is all correct. ??
Forum: Hacks
In reply to: SQL sum of custom field split into monthsUpdate:
The following code works to an extent.
It outputs the sum of the custom field ‘total_invoice_cost per month ONLY if the custom field ‘paid’ has a value of ‘yes’. (which is what I wanted)<?php global $wpdb; $results = $wpdb->get_results("SELECT SUM(x.total_invoice_cost),CONCAT( YEAR(x.post_date), '-', MONTH(x.post_date) ) AS grandtotal FROM ( SELECT ID, total_invoice_cost.meta_value AS total_invoice_cost, paid.meta_value AS paid, wp_posts.post_date FROM wp_posts LEFT OUTER JOIN (SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key='paid') paid ON wp_posts.id=paid.post_id LEFT OUTER JOIN (SELECT post_id, meta_value, meta_key FROM wp_postmeta WHERE meta_key='total_invoice_cost') total_invoice_cost ON wp_posts.id=total_invoice_cost.post_id ) x WHERE x.total_invoice_cost IS NOT NULL AND x.paid='yes' GROUP BY CONCAT( YEAR(x.post_date), '-', MONTH(x.post_date) )"); print "<p>\n"; print_r($results); print "</p>"; ?>
However, it outputs the results like this:
Array ( [0] => stdClass Object ( [SUM(x.total_invoice_cost)] => 150 [grandtotal] => 2015-4 ) )
How can I edit this so that it shows it as £150 – 2015-4? I assume it has something to do with printing as a result, but I’m not sure how to change this.
Forum: Everything else WordPress
In reply to: A site is offering my free wordpress theme@jan are themes on www.ads-software.com not licensed under GPL also? It was my understanding that they were.
Also agree with it being dirty and dishonest.
@yavor perhaps you could approach them and tell them that its your theme and they shouldn’t accept donations for it. It may ‘scare’ them and they may remove it.
Forum: Everything else WordPress
In reply to: A site is offering my free wordpress themeI’m not sure if they are able to have the donation button. Have a look at this page, it may help.
Hi James,
I was being silly and was entering my code into a static block but using the wrong code to call it. Everything is working great now. ??
Update:
– I added this into a static block
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
– then this into my WordPress page template
<?php $staticblock = get_static_block("new_products"); echo $staticblock; ?>
And it worked ?? I assume the same process will work for showing all products.
UPDATE
I’ve discovered it isn’t as simple as making a block and calling it.
I’ve created the following files:
app/code/local/Mage/Catalog/Block/Product/Mostviewed.php
app/code/local/Mage/Catalog/Block/Product/Bestseller.phpAfter this, I created a static block in magento called ‘Popular Products’ with the identifier ‘popular_products’. In the block I then placed:
<block type="catalog/product_mostviewed" name="popular.products" template="catalog/product/mostviewed.phtml"/>
And called the block trying both the following:
<?php the_block("popular_products"); ?>
<?php the_block("popular.products"); ?>
Still the block can’t be found ??
UPDATE:
I managed to connect to Mage.php. Even though I had updated the functions.php, I hadn’t made a ‘local’ directory so I was missing that path.
Once I made the new functions.php, Mage.php was suddenly found.
I’ve now managed to get Magento and WordPress to connect (yay).
My next problem:
I added a block for test purposes:
<?php the_block("footer_links"); ?>
and it worked like a charm, however, when I try to add my own custom block
<?php the_block("popular_products"); ?>
The output is ‘sorry that block couldn’t be found’. What am I doing wrong?
Forum: Plugins
In reply to: [WP-ShowHide] Justify Text Inside ShowHideHi speed101,
try typing this in to your themes style.css :
#pressrelease-content { text-align: justify; }
Forum: Everything else WordPress
In reply to: User Specific Information From DatabaseAfter a lot of research and trial and error I have progressed.
First I created several users in the WordPress dashboard and set them to subscribers. (I will later create a register page)
Next, I installed the ‘csv importer’ plugin and made a post for each car and assigned the specific user.
Next I went to wp-admin/includes/meta-boxes.php and changed
$visibility = 'public'; $visibility_trans = __('Public');
to
$visibility = 'private'; $visibility_trans = __('Private');
This now means that when I upload a new post, it is set to private by default meaning only the assigned user can view that post.
When a user logs in now, all they see are their assigned cars.
HOWEVER
After using the csv importer, the posts are all set to private but they are still public. I have to manually go to each post and re-click private (even though it is already on private). When I create a new post on WordPress however, the post IS private.
So my problem now is how do I make sure the posts uploaded with ‘csv importer’ actually go to private?
Forum: Everything else WordPress
In reply to: User Specific Information From DatabaseHi,
I had a look at the two links you sent me. I hope the questions I am about to ask are not stupid.
If I was to create custom post types, would I create individual ones eg. ‘type’, ‘year’? or would each user have their own custom post?
Once I have done this, how would I go about making sure the user only sees the information specific to them? Find a user plugin which only shows the user their ‘custom post’?