I am trying to show the product count next to the manufacturers. I am also trying to hide any manufacture with 0 product count, so only show the manufacture if the product count contains a product. Else hide it.
I have attempted the following below. However, the product count is just showing as (0) on all manufactures. Doesn't get the count properly.
I am using OC 2.0.3.1.
Open file catalog\controller\product\manufacturer.php
Find
$this->load->model('catalog/manufacturer');
and add below code after that line
$this->load->model('catalog/product');
Find
'name' => $result['name'],
and replace with
'name' => $result['name'] . ' (' . $this->model_catalog_product->getTotalProducts(array('filter_manufacturer_id' => $result['manufacturer_id'])) . ')',
It's not working. Any help would be appreciated.
Related
I have a website selling digital postbox numbers, currently only one city so I used custom order numbers plugin to change the order numbers automaticallly to sequential numbers to match the postbox numbers I can provide.
Now I'm adding 2 more cities, and I want to create a separate numbering system for them as each city's postboxes starts with the number 1200, so I will not be able to provide 2 postboxes with number 1200 for example for 2 cities if I'm using custom order numbers.
is there a solution for this?
my only idea is to create subdomains for each city with different WP installation
so simply it should be
Product A = Numbers start from 1200, +1 added for each sale
Product B = numbers start from 1200, +1 added for each sale
Product C = numbers start from 1200, +1 added for each sale
Try looking into a prefix or suffix for your order ids which will denote which city its been purchased for
add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number', 1, 2);
function change_woocommerce_order_number( $order_id, $order ) {
$prefix = '#CITY-';
// you will need to get your city as a variable to pass in to priffix
$suffix = '-' . date(Y);
// You can use either one of $order->id (or) $order_id
// Both will work
return $prefix . $order->id . $suffix;
}
I am trying to have custom count in woocommerce categories. So categories don't show if they have products that are out of stock or are marked as do not display on website.
I can't seem to change the value that displays on the categories page.
I have tried:
Changing the value in the count column of wp_term_taxonomy table.
Changing the value in the wp_termmeta of metakey product_count_product_tag
With both of these changes the count displayed doesn't seem to change.
I can't seem to find anywhere the value might be being cached.
Nor can I find any hooks that might alter the value.
So I have found at least a partial answer to my question.
The count is stored in the term_taxonomy table but when it is displaying the subcategories it shows all of them
I found a hook that allows you to change the args so you can hide empty since by default hide empty = false and pad_count = 1 so you need to set hide_empty to true and set pad_count = 0 (otherwise it adds one to the count and none of them are 0)
add_filter( 'woocommerce_product_subcategories_args','hide_subcategories_with_no_products', 10, 1 );
function hide_subcategories_with_no_products( $args ) {
$args['hide_empty'] = 1;
$args['hierarchical'] = true;
$args['pad_counts'] = 0;
return $args;
}
NOTE: for me the woocommerce_product_subcategories_hide_empty HOOK did not work. I think this may be because either it is using count(*) instead of the count column or the pad_count being set to 1
I have 3 bapi named BAPI_SALESORDER_GETLIST,BAPI_SALESORDER_GETSTATUS and BAPI_SALESORDER_GETDETAILBOS.
Here in the first bapi I have to input Customer Number and Sales Organization as input and retrieve Sales Document Number (SD_DOC) and from_Date.
This Sales Document Number(SD_Doc) retrieved from 1st BAPI has to be given as input to other bapi named BAPI_SALESORDER_GETSTATUS to retrieve some data.
and the same Sales Document Number has to be given input to the third BAPI that is BAPI_SALESORDER_GETDETAILBOS to retrieve some particular data.
To my knowledge I have done some work with the bapi and up till now in the service I have created I have given only customer number as input to the URI in the SAP GATEWAY CLIENT
for example:
/sap/opu/odata/sap/ZOPENSALESORDER_SRV/openSalesOrderSet?$filter=Customerno eq '1'
If anyone can help regarding this would be very grateful for that.
First of all i would like to tell you guys that I have THREE bapis out of which i rquired my data.1)BAPI_SALESORDER_GETLIST 2)BAPI_SALESORDER_GETSTATUS and 3)BAPI_SALESORDER_GETDETAILBOS.
For the First Bapi i'll give input Customer Number(KUNNR) and Sales Organization(VKORG) , then i'll get sale document number as output.
This sales document number will be given to the next bapi BAPI_SALESORDER_GETSTATUS to obtain other relevant data.
And the same sales document number will also be given to the third bapi BAPI_SALESORDER_GETDETAILBOS.
I'll first tell you the steps
Specify the input parameters in the Import parameter. In my scenario i have kunnr and vkorg. click here for the image1
Then internal tables are already made as i'm only going to use the standard bapi's. so in table section just write the name of you bapi and you are good to go.click here for the image2
Then in the source section start your coding:
enter code here
DATA: "lt_bapiorders TYPE TABLE OF bapiorders,
lt_statusinfo TYPE TABLE OF bapisdstat,
lt_orderitem TYPE TABLE OF bapisditbos,
lt_orderscheduleline TYPE TABLE OF bapisdhedu.
FIELD-SYMBOLS: <lfs_order> TYPE bapiorders,
<lfs_statinfo> TYPE bapisdstat,
<lfs_orderitem> TYPE bapisditbos,
<lfs_orderscheduleline> TYPE bapisdhedu.
"Fecth all the sales order for a customer
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = kunnr
sales_organization = vkorg
TABLES
sales_orders = order.
"Get status for the sales order
LOOP AT order ASSIGNING <lfs_order> .
IF <lfs_order> IS ASSIGNED.
WRITE:/ <lfs_order>-sd_doc.
"This function call is for getting the status of the
"Sales document number derived from the BAPI_SALESORDER_GETLIST
CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
EXPORTING
salesdocument = <lfs_order>-sd_doc
TABLES
statusinfo = lt_statusinfo.
APPEND LINES OF lt_statusinfo TO statusinfo_lt.
"Read Processing and delivery Status
READ TABLE lt_statusinfo ASSIGNING <lfs_statinfo> INDEX 1.
IF sy-subrc EQ 0.
WRITE: / 'Delivery Status', <lfs_statinfo>-dlv_stat_h,
'Required Date', <lfs_statinfo>-req_date_h,
'Delivery Number',<lfs_statinfo>-deliv_numb,
'Delivery Date',<lfs_statinfo>-deliv_date.
ENDIF.
CALL FUNCTION 'BAPI_SALESORDER_GETDETAILBOS'
EXPORTING
salesdocument = <lfs_order>-sd_doc
TABLES
orderitems = lt_orderitem
orderschedulelines = lt_orderscheduleline.
APPEND LINES OF lt_orderitem to orderitem.
"Read Processing and delivery Details
READ TABLE lt_orderitem ASSIGNING <lfs_orderitem> INDEX 1.
IF sy-subrc EQ 0.
WRITE: / 'Material', <lfs_orderitem>-material,
'Plant', <lfs_orderitem>-plant,
'Short-text',<lfs_orderitem>-short_text,
'Req_qty',<lfs_orderitem>-req_qty,
'doc_number',<lfs_orderitem>-doc_number.
ENDIF.
APPEND LINES OF lt_orderscheduleline to orderscheduleline.
"Read processing and delivery details -goods issue time
READ TABLE orderscheduleline ASSIGNING <lfs_orderscheduleline> INDEX 1.
IF sy-subrc EQ 0.
WRITE: / 'Goods Issue Date', <lfs_orderscheduleline>-gi_date.
ENDIF.
.
ENDIF.
ENDLOOP.
Then execute it.
I try to display my taxonomy terms through views, from my vocbulary
now it goes like this
term1 name
term1 img
I need to add count of all nodes with that term, and it will look like ->
term1 name
term1 img
count of all nodes with *term1*
so far, my idea was to display term id in additional field, after use preprocess function, and run SQL query to count all nodes with that term,
but i think there must be a easy way, looking for ideas
Create Taxonomy Views.
Add relationship to the node (in case if you want to count number of nodes).
Enable grouping (Group by)
(or "Use aggregation" toggle in D7, then set the "Aggregation Settings" for each field)
In Style Settings/Format set Grouping field to 'Term ID' or 'Node ID' (depends of your query)
Add new field 'Node: NID' and set Group type to: Count
That should give you the count
Ref : http://drupal.org/node/603868#comment-4421144
Here is a simple method available for the same :
$tid = 'Enter tid number say 5';
$nids = taxonomy_select_nodes($tid, FALSE);
// count node here
$count = count($nids);
// you can load node content here
$nodes = node_load_multiple($nids);
I use JetPack stats to follow the stats for my blog. I would like to extract the top 10 most-viewed posts for a given period (e.g. last month).
I used the WordPress stats plugin API before which worked nicely, but after upgrade to JetPack this doesn't work anymore.
Is there an API which allows me to query the number of view counts for a post?
Inside the Database
This option is recorded in the database and is used by the Dashboard widget:
get_option( 'stats_cache' );
It returns an array like this:
array(
['7375996b7a989f95a6ed03ca7c899b1f'] => array(
[1353440532] => array(
[0] => array(
['post_id'] => 0
['post_title'] => 'Home page'
['post_permalink'] => 'http://www.example.com/'
['views'] => 1132
)
[1] => array(
['post_id'] => 4784
['post_title'] => 'Hello World!'
['post_permalink'] =>
['views'] => 493
)
/* till item [9] */
Querying WordPress.com
It is possible to call the following Jetpack function:
if( function_exists( 'stats_get_csv' ) ) {
$top_posts = stats_get_csv( 'postviews', 'period=month&limit=30' );
}
Which returns:
array(
[0] => array(
['post_id'] => 0
['post_title'] => 'Home page'
['post_permalink'] => 'http://www.example.com/'
['views'] => 6806
)
[1] => array(
['post_id'] => 8005
['post_title'] => 'Hello World!'
['post_permalink'] =>
['views'] => 1845
)
/* till item [29] */
Function get_stats_csv
/plugins/jetpack/modules/stats.php
The function get_stats_csv calls http://stats.wordpress.com/csv.php. If we visit this address, we get this response:
Error: api_key is a required parameter.
Required parameters: api_key, blog_id or blog_uri.
Optional parameters: table, post_id, end, days, limit, summarize.
Parameters:
api_key String A secret unique to your WordPress.com user account.
blog_id Integer The number that identifies your blog.
Find it in other stats URLs.
blog_uri String The full URL to the root directory of your blog.
Including the full path.
table String One of views, postviews, referrers, referrers_grouped,
searchterms, clicks, videoplays.
post_id Integer For use with postviews table.
end String The last day of the desired time frame.
Format is 'Y-m-d' (e.g. 2007-05-01)
and default is UTC date.
days Integer The length of the desired time frame.
Default is 30. "-1" means unlimited.
period String For use with views table and the 'days' parameter.
The desired time period grouping. 'week' or 'month'
Use 'days' as the number of results to return
(e.g. '&period=week&days=12' to return 12 weeks)
limit Integer The maximum number of records to return.
Default is 100. "-1" means unlimited.
If days is -1, limit is capped at 500.
summarize Flag If present, summarizes all matching records.
format String The format the data is returned in,
'csv', 'xml' or 'json'.
Default is 'csv'.
Non-working query example:
?api_key=123456789abc&blog_id=155&table=referrers&days=30&limit=-1&summarize
Result format is csv with one row per line and column names in first row.
Strings containing double quotes, commas, or "\n" are enclosed in double-quotes.
Double-qoutes in strings are escaped by inserting another double-quote.
Example: "pet food" recipe
Becomes: """pet food"" recipe"
Developers, please cache the results for at least 180 seconds.