I would like to know how to output woocommerce variable sku's. By default woocommerce should be able to change the sku if product variations are clicked but that function doesn't seem to work.
Any help would be grateful.
I know how to output the parent sku
$product->get_sku()
you could use
$available_variations = $product->get_available_variations(); which will create an array of all the variations. Then use a forloop to loop through the array to get each sku.
thanks
Related
I am trying to add a run with the add_run endpoint, but in my automation code I only have the test cases ids but not the project id (which according the the docs is mandatory).
Right now I am doing:
get all projects with /get_projects
get all cases /get_cases/{project_id}
Then I loop over the cases I get and add the project_id to the case so I could create an add_run with the proper project_id.
This seems like the wrong way to do it.
Anybody has a better solution?
Also is there a way to create a run without a project_id? for example if I have a sanity run that includes cases from many projects.
Any help is appreciated.
You can do the following to get the parent project ID:
get the case by ID and capture value of the suite_id field
get the parent suite by the value of the suite_id field and capture value of the project_id field <--- here you have your project ID and can use it for creating runs.
I am able to retrieve the data between the nodes, but not from in the node itself. I searched far and wide, but can't seem to find a solution for this.
My XML looks like the following:
And this XML is saved inside a nvarchar column called fileXML in SQL (Server 2008R2).
I want to retrieve the History Date, which is inside the node name.
My current code which is retrieving the "18" from the node value is the following:
, fileXML.value('(/commands/command/measure/categories/category/components/component/history)[1]', 'varchar(100)') as HisDate
Like you can see on the picture above, this is working.
But I can't seem to retrieve the info from within the node.
I searched on the web, and tried several things like:
fileXML.value('(/commands/command/measure/categories/category/components/component/history.name)[1]', 'varchar(100)') as HisDate
fileXML.value('(/commands/command/measure/categories/category/components/component/history/local-name)[1]', 'varchar(100)') as HisDate
fileXML.value('(/commands/command/measure/categories/category/components/component/history/local-name(.))[1]', 'varchar(100)') as HisDate
Where the first 2 became a NULL value, and the last one gave an error message that a function is not supported. I can give much more example on what I tried, but this would make the post a bit messy.
Any help is greatly appreciated.
date is an attribute of the history element. So your path should be
/commands/command/measure/categories/category/components/component/history/#date
Untested as you supplied the XML as a picture.
I am trying to find a specific value inside an array. The array is composed from data in MySQL database and looks like:
info = [#<Info1: bla, Info2: blo>,#<Info1: bli, Info2, Ble>]
Now I want to get every Info1's value from it, but I do not know how.
The array was formed by calling
info = Info.find(:all)
Can anyone help me?
I am using Rails 2.2.2 (don't ask, can't do anything about it) and Ruby 1.8.
Edit: More details
Info is a database, where Info1 and info 2 are the columns. Calling it with info = Info.find(:all) returns the array above.
What I have tried so far involves trying to go through the array with each, but so far no luck.
Most of what I have tried like
a.grep(/^info1/)
and
info.select(|i| i.name == "info1")
all return empty arrays
Edit
Nevermind, I found the answer. I was thinking too weird. The answer is
info.each do |object|
puts object.info2
end
What's your selection criteria? You can do something like
info.select{|i| i.name == 'hello' }
and you will get all the Info objects with name = 'hello'.
But I would prefer to change the query, if you can, to filter them in the database query directly.
I have a case where I need to post and array of numbers to the server side. E.g:
I have an order that have a list of products with one to many relation ships.
The question is how to post only array of id's for current order:
Now I have such result:
{"orders":[{"id":0,"Products":[{"productId":6},{"productId":7},{"productId":5},{"productId":3}]},{"id":1,.....]}
But I want to make it
{"orders":[{"id":0,"Products":[6,7,5,3]},{"id":1,.....]}
Any ideas ?
Update 1
I think I have found a solution
I have add method that fetch id's of my order products it's look like this
-(NSArray *)productsIds {
return [self.products.array valueForKeyPath:ProductAttributes.productId];
}
and add such a thing to my mapping code part.
[orderSerializationMapping addAttributeMappingsFromDictionary:#{#"productsIds" : #"Products"}];
And now result is
{"orders":[{"id":5,"Products":[17,13,16,11,12,19]},......]
You don't need add a method to fetch the id's. Setup your mapping like this:
[orderSerializationMapping addAttributeMappingsFromDictionary:#{#"products.productID": #"Products"}];
I'm new to CakePHP and I could do with some newbie advice please.
I'm creating an invoicing application and the way I have it set up is with seperate tables (and so Models and Controlllers) for Invoices and Items. The Invoice table holds the data such as 'Invoice Number', 'Date' and 'Client ID' for example, and the Items table stores individual records/items that make up each invoice with 'Quantity', 'Unit Price' etc. The two are associated correctly.
When I call the 'edit' view for Invoices, obviously passing an ID, I retrieve the record and then also loop through the all associated records returned from the Items table to - all works as planned and are retrieved and displayed correctly.
What I want to be able to do from this view though, is to be able to delete individual items from the invoice by clicking on a delete button next to each - ideally with a confirmation box. How would this be acheived exactly? What would be the best method? Would I use a function in the Items controller to do this without leaving the page? How would I call the function in that controller from the Invoice controller/view? Or would another method such as the CakePHP query() function be used for this?
I hope I've explained this setup clearly enough for someone to offer any help and/or advice for which I would be very thankful.
Thanks in advance
The simple way:
In your Invoice/view.ctp
Inside your foreach loop you would do something like this:
//this is loose code since you have not pasted any in your question
<?php echo $this->Html->link('Delete', array('controller'=>'Item', 'action'=>'delete', $item['Item']['id'])); ?>
then create the function in your ItemController.php
function delete($id=NULL){
if($id){
$this->Item->delete($id);
$this->Session->setFlash(__('Invoice item deleted', true));
$this->redirect($this->referer());
}
}